diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index 00dc83fa80a..a8b5fdbcf7c 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -124,10 +124,7 @@ interface Object { propertyIsEnumerable(v: string): boolean; } -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { +interface ObjectConstructor { new (value?: any): Object; (): any; (value: any): any; @@ -221,6 +218,11 @@ declare var Object: { keys(o: any): string[]; } +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + /** * Creates a new function. */ @@ -255,8 +257,8 @@ interface Function { caller: Function; } -declare var Function: { - /** +interface FunctionConstructor { + /** * Creates a new function. * @param args A list of arguments the function accepts. */ @@ -265,6 +267,8 @@ declare var Function: { prototype: Function; } +declare var Function: FunctionConstructor; + interface IArguments { [index: number]: any; length: number; @@ -424,24 +428,31 @@ interface String { [index: number]: string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { +interface StringConstructor { new (value?: any): String; (value?: any): string; prototype: String; fromCharCode(...codes: number[]): string; } +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; } -declare var Boolean: { + +interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; } +declare var Boolean: BooleanConstructor; + interface Number { /** * Returns a string representation of an object. @@ -468,8 +479,7 @@ interface Number { toPrecision(precision?: number): string; } -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { +interface NumberConstructor { new (value?: any): Number; (value?: any): number; prototype: Number; @@ -499,6 +509,9 @@ declare var Number: { POSITIVE_INFINITY: number; } +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + interface TemplateStringsArray extends Array { raw: string[]; } @@ -768,7 +781,7 @@ interface Date { toJSON(key?: any): string; } -declare var Date: { +interface DateConstructor { new (): Date; new (value: number): Date; new (value: string): Date; @@ -794,6 +807,8 @@ declare var Date: { now(): number; } +declare var Date: DateConstructor; + interface RegExpMatchArray extends Array { index?: number; input?: string; @@ -834,9 +849,11 @@ interface RegExp { // Non-standard extensions compile(): RegExp; } -declare var RegExp: { + +interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; + prototype: RegExp; // Non-standard extensions $1: string; @@ -851,64 +868,87 @@ declare var RegExp: { lastMatch: string; } +declare var RegExp: RegExpConstructor; + interface Error { name: string; message: string; } -declare var Error: { + +interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; prototype: Error; } +declare var Error: ErrorConstructor; + interface EvalError extends Error { } -declare var EvalError: { + +interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; prototype: EvalError; } +declare var EvalError: EvalErrorConstructor; + interface RangeError extends Error { } -declare var RangeError: { + +interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; prototype: RangeError; } +declare var RangeError: RangeErrorConstructor; + interface ReferenceError extends Error { } -declare var ReferenceError: { + +interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; prototype: ReferenceError; } +declare var ReferenceError: ReferenceErrorConstructor; + interface SyntaxError extends Error { } -declare var SyntaxError: { + +interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; prototype: SyntaxError; } +declare var SyntaxError: SyntaxErrorConstructor; + interface TypeError extends Error { } -declare var TypeError: { + +interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; prototype: TypeError; } +declare var TypeError: TypeErrorConstructor; + interface URIError extends Error { } -declare var URIError: { + +interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; prototype: URIError; } +declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1111,7 +1151,8 @@ interface Array { [n: number]: T; } -declare var Array: { + +interface ArrayConstructor { new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; @@ -1121,3 +1162,5 @@ declare var Array: { isArray(arg: any): boolean; prototype: Array; } + +declare var Array: ArrayConstructor; diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts new file mode 100644 index 00000000000..d5898b35a71 --- /dev/null +++ b/bin/lib.core.es6.d.ts @@ -0,0 +1,4803 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +declare var Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + +interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +declare var Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare var Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare var RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +declare var Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +declare var EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +declare var RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +declare var ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +declare var SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +declare var TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +declare var URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + +declare var Array: ArrayConstructor; +declare type PropertyKey = string | number | Symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + // [Symbol.toStringTag]: string; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): Symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): Symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: Symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + hasInstance: Symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + isConcatSpreadable: Symbol; + + /** + * A Boolean value that if true indicates that an object may be used as a regular expression. + */ + isRegExp: Symbol; + + /** + * A method that returns the default iterator for an object.Called by the semantics of the + * for-of statement. + */ + iterator: Symbol; + + /** + * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive + * abstract operation. + */ + toPrimitive: Symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built- in method Object.prototype.toString. + */ + toStringTag: Symbol; + + /** + * An Object whose own property names are property names that are excluded from the with + * environment bindings of the associated objects. + */ + unscopables: Symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): Symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns a new function object that is identical to the argument object in all ways except + * for its identity and the value of its HomeObject internal slot. + */ + toMethod(newHome: Object): Function; + + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + name: string; +} + +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. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + +interface Array { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + contains(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + //[Symbol.iterator](): Iterator; + next(): IteratorResult; +} + +interface Iterable { + //[Symbol.iterator](): Iterator; +} + +interface GeneratorFunction extends Function { + +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Generator extends Iterator { + next(value?: any): IteratorResult; + throw (exception: any): IteratorResult; + return (value: T): IteratorResult; + // [Symbol.toStringTag]: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + // [Symbol.toStringTag]: string; +} + +interface RegExp { + // [Symbol.isRegExp]: boolean; + + /** + * Matches a string with a regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + match(string: string): string[]; + + /** + * Replaces text in a string, using a regular expression. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of rgExp in stringObj. + */ + replace(string: string, replaceValue: string): string; + + search(string: string): number; + + /** + * Returns an Array object into which substrings of the result of converting string to a String + * have been stored. The substrings are determined by searching from left to right for matches + * of the this value regular expression; these occurrences are not part of any substring in the + * returned array, but serve to divide up the String value. + * + * If the regular expression that contains capturing parentheses, then each time separator is + * matched the results (including any undefined results) of the capturing parentheses are spliced. + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than limit elements. + */ + split(string: string, limit?: number): string[]; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + unicode: boolean; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value?: V): Map; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator<[K,V]>; + // [Symbol.toStringTag]: string; +} + +interface MapConstructor { + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + // [Symbol.toStringTag]: string; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator; + // [Symbol.toStringTag]: string; +} + +interface SetConstructor { + new (): Set; + new (iterable: Iterable): Set; + prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: string; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: Iterable): WeakSet; + prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + // [Symbol.toStringTag]: 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. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin: number, end?: number): ArrayBuffer; + + // [Symbol.toStringTag]: string; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + + // [Symbol.toStringTag]: string; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: Uint8ClampedArray): Uint8ClampedArray; + new (array: number[]): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} +declare var Uint16Array: Uint16ArrayConstructor; + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handeler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare var Reflect: { + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + construct(target: Function, argumentsList: ArrayLike): any; + defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + deleteProperty(target: any, propertyKey: PropertyKey): boolean; + enumerate(target: any): Iterator; + get(target: any, propertyKey: PropertyKey, receiver?: any): any; + getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + getPrototypeOf(target: any): any; + has(target: any, propertyKey: string): boolean; + has(target: any, propertyKey: Symbol): boolean; + isExtensible(target: any): boolean; + ownKeys(target: any): Array; + preventExtensions(target: any): boolean; + set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + setPrototypeOf(target: any, proto: any): boolean; +}; + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | Promise): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param init A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * 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: (T | Promise)[]): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of values. + * @returns A new Promise. + */ + all(values: Promise[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | Promise)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | Promise): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} \ No newline at end of file diff --git a/bin/lib.d.ts b/bin/lib.d.ts index c18bd4ff8b4..f2635cc65fa 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -124,10 +124,7 @@ interface Object { propertyIsEnumerable(v: string): boolean; } -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { +interface ObjectConstructor { new (value?: any): Object; (): any; (value: any): any; @@ -221,6 +218,11 @@ declare var Object: { keys(o: any): string[]; } +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + /** * Creates a new function. */ @@ -255,8 +257,8 @@ interface Function { caller: Function; } -declare var Function: { - /** +interface FunctionConstructor { + /** * Creates a new function. * @param args A list of arguments the function accepts. */ @@ -265,6 +267,8 @@ declare var Function: { prototype: Function; } +declare var Function: FunctionConstructor; + interface IArguments { [index: number]: any; length: number; @@ -424,24 +428,31 @@ interface String { [index: number]: string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { +interface StringConstructor { new (value?: any): String; (value?: any): string; prototype: String; fromCharCode(...codes: number[]): string; } +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; } -declare var Boolean: { + +interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; } +declare var Boolean: BooleanConstructor; + interface Number { /** * Returns a string representation of an object. @@ -468,8 +479,7 @@ interface Number { toPrecision(precision?: number): string; } -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { +interface NumberConstructor { new (value?: any): Number; (value?: any): number; prototype: Number; @@ -499,6 +509,9 @@ declare var Number: { POSITIVE_INFINITY: number; } +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + interface TemplateStringsArray extends Array { raw: string[]; } @@ -768,7 +781,7 @@ interface Date { toJSON(key?: any): string; } -declare var Date: { +interface DateConstructor { new (): Date; new (value: number): Date; new (value: string): Date; @@ -794,6 +807,8 @@ declare var Date: { now(): number; } +declare var Date: DateConstructor; + interface RegExpMatchArray extends Array { index?: number; input?: string; @@ -834,9 +849,11 @@ interface RegExp { // Non-standard extensions compile(): RegExp; } -declare var RegExp: { + +interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; + prototype: RegExp; // Non-standard extensions $1: string; @@ -851,64 +868,87 @@ declare var RegExp: { lastMatch: string; } +declare var RegExp: RegExpConstructor; + interface Error { name: string; message: string; } -declare var Error: { + +interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; prototype: Error; } +declare var Error: ErrorConstructor; + interface EvalError extends Error { } -declare var EvalError: { + +interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; prototype: EvalError; } +declare var EvalError: EvalErrorConstructor; + interface RangeError extends Error { } -declare var RangeError: { + +interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; prototype: RangeError; } +declare var RangeError: RangeErrorConstructor; + interface ReferenceError extends Error { } -declare var ReferenceError: { + +interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; prototype: ReferenceError; } +declare var ReferenceError: ReferenceErrorConstructor; + interface SyntaxError extends Error { } -declare var SyntaxError: { + +interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; prototype: SyntaxError; } +declare var SyntaxError: SyntaxErrorConstructor; + interface TypeError extends Error { } -declare var TypeError: { + +interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; prototype: TypeError; } +declare var TypeError: TypeErrorConstructor; + interface URIError extends Error { } -declare var URIError: { + +interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; prototype: URIError; } +declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1111,7 +1151,8 @@ interface Array { [n: number]: T; } -declare var Array: { + +interface ArrayConstructor { new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; @@ -1122,6 +1163,8 @@ declare var Array: { prototype: Array; } +declare var Array: ArrayConstructor; + ///////////////////////////// /// IE10 ECMAScript Extensions ///////////////////////////// @@ -1489,7 +1532,7 @@ interface Uint32Array extends ArrayBufferView { set(array: number[], offset?: number): void; /** - * Gets a new Uint32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ @@ -1754,6 +1797,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -1765,6 +1809,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -1777,10 +1822,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 26d30d3a027..1fedb4e266f 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -647,6 +647,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -658,6 +659,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -670,10 +672,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts new file mode 100644 index 00000000000..c8c00f5712c --- /dev/null +++ b/bin/lib.es6.d.ts @@ -0,0 +1,17197 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +declare var Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + +interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +declare var Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare var Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare var RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +declare var Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +declare var EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +declare var RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +declare var ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +declare var SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +declare var TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +declare var URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + +declare var Array: ArrayConstructor; +declare type PropertyKey = string | number | Symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + // [Symbol.toStringTag]: string; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): Symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): Symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: Symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + hasInstance: Symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + isConcatSpreadable: Symbol; + + /** + * A Boolean value that if true indicates that an object may be used as a regular expression. + */ + isRegExp: Symbol; + + /** + * A method that returns the default iterator for an object.Called by the semantics of the + * for-of statement. + */ + iterator: Symbol; + + /** + * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive + * abstract operation. + */ + toPrimitive: Symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built- in method Object.prototype.toString. + */ + toStringTag: Symbol; + + /** + * An Object whose own property names are property names that are excluded from the with + * environment bindings of the associated objects. + */ + unscopables: Symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): Symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns a new function object that is identical to the argument object in all ways except + * for its identity and the value of its HomeObject internal slot. + */ + toMethod(newHome: Object): Function; + + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + name: string; +} + +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. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + +interface Array { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + contains(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + //[Symbol.iterator](): Iterator; + next(): IteratorResult; +} + +interface Iterable { + //[Symbol.iterator](): Iterator; +} + +interface GeneratorFunction extends Function { + +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Generator extends Iterator { + next(value?: any): IteratorResult; + throw (exception: any): IteratorResult; + return (value: T): IteratorResult; + // [Symbol.toStringTag]: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + // [Symbol.toStringTag]: string; +} + +interface RegExp { + // [Symbol.isRegExp]: boolean; + + /** + * Matches a string with a regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + match(string: string): string[]; + + /** + * Replaces text in a string, using a regular expression. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of rgExp in stringObj. + */ + replace(string: string, replaceValue: string): string; + + search(string: string): number; + + /** + * Returns an Array object into which substrings of the result of converting string to a String + * have been stored. The substrings are determined by searching from left to right for matches + * of the this value regular expression; these occurrences are not part of any substring in the + * returned array, but serve to divide up the String value. + * + * If the regular expression that contains capturing parentheses, then each time separator is + * matched the results (including any undefined results) of the capturing parentheses are spliced. + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than limit elements. + */ + split(string: string, limit?: number): string[]; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + unicode: boolean; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value?: V): Map; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator<[K,V]>; + // [Symbol.toStringTag]: string; +} + +interface MapConstructor { + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + // [Symbol.toStringTag]: string; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator; + // [Symbol.toStringTag]: string; +} + +interface SetConstructor { + new (): Set; + new (iterable: Iterable): Set; + prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: string; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: Iterable): WeakSet; + prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + // [Symbol.toStringTag]: 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. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin: number, end?: number): ArrayBuffer; + + // [Symbol.toStringTag]: string; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + + // [Symbol.toStringTag]: string; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: Uint8ClampedArray): Uint8ClampedArray; + new (array: number[]): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} +declare var Uint16Array: Uint16ArrayConstructor; + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handeler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare var Reflect: { + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + construct(target: Function, argumentsList: ArrayLike): any; + defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + deleteProperty(target: any, propertyKey: PropertyKey): boolean; + enumerate(target: any): Iterator; + get(target: any, propertyKey: PropertyKey, receiver?: any): any; + getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + getPrototypeOf(target: any): any; + has(target: any, propertyKey: string): boolean; + has(target: any, propertyKey: Symbol): boolean; + isExtensible(target: any): boolean; + ownKeys(target: any): Array; + preventExtensions(target: any): boolean; + set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + setPrototypeOf(target: any, proto: any): boolean; +}; + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | Promise): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param init A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * 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: (T | Promise)[]): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of values. + * @returns A new Promise. + */ + all(values: Promise[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | Promise)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | Promise): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +}///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + + /** + * Converts a number to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; +} + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: string[]; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface MouseEventInit { + bubbles?: boolean; + cancelable?: boolean; + view?: Window; + detail?: number; + screenX?: number; + screenY?: number; + clientX?: number; + clientY?: number; + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + button?: number; + buttons?: number; + relatedTarget?: EventTarget; +} + +interface WebGLContextAttributes { + alpha?: boolean; + depth?: boolean; + stencil?: boolean; + antialias?: boolean; + premultipliedAlpha?: boolean; + preserveDrawingBuffer?: boolean; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + hidden: any; + readyState: any; + onmouseleave: (ev: MouseEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + onmove: (ev: MSEventObj) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onhelp: (ev: Event) => any; + ondragleave: (ev: DragEvent) => any; + className: string; + onfocusin: (ev: FocusEvent) => any; + onseeked: (ev: Event) => any; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + dir: string; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + ondeactivate: (ev: UIEvent) => any; + ondatasetchanged: (ev: MSEventObj) => any; + onrowsdelete: (ev: MSEventObj) => any; + sourceIndex: number; + onloadstart: (ev: Event) => any; + onlosecapture: (ev: MSEventObj) => any; + ondragenter: (ev: DragEvent) => any; + oncontrolselect: (ev: MSEventObj) => any; + onsubmit: (ev: Event) => any; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + oncanplaythrough: (ev: Event) => any; + onbeforeupdate: (ev: MSEventObj) => any; + onfilterchange: (ev: MSEventObj) => any; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + onsuspend: (ev: Event) => any; + onmouseenter: (ev: MouseEvent) => any; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + onmouseout: (ev: MouseEvent) => any; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + onvolumechange: (ev: Event) => any; + oncellchange: (ev: MSEventObj) => any; + onrowexit: (ev: MSEventObj) => any; + onrowsinserted: (ev: MSEventObj) => any; + onpropertychange: (ev: MSEventObj) => any; + filters: any; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + onwaiting: (ev: Event) => any; + onresizestart: (ev: MSEventObj) => any; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + language: string; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + onratechange: (ev: Event) => any; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: ProgressEvent) => any; + ondblclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: MouseEvent) => any; + onloadedmetadata: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + onerror: (ev: ErrorEvent) => any; + onplay: (ev: Event) => any; + onresizeend: (ev: MSEventObj) => any; + onplaying: (ev: Event) => any; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + onabort: (ev: UIEvent) => any; + ondataavailable: (ev: MSEventObj) => any; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + onkeypress: (ev: KeyboardEvent) => any; + onloadeddata: (ev: Event) => any; + onbeforedeactivate: (ev: UIEvent) => any; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + onselectstart: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + oncut: (ev: DragEvent) => any; + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + onended: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onrowenter: (ev: MSEventObj) => any; + onload: (ev: Event) => any; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + onmscontentzoom: (ev: MSEventObj) => any; + oncuechange: (ev: Event) => any; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + draggable: boolean; + dataset: DOMStringMap; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: any): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: any): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; + msGetInputContext(): MSInputMethodContext; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new(): HTMLElement; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions, MSDocumentExtensions, GlobalEventHandlers { + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + /** + * Retrieves the collection of user agents and versions declared in the X-UA-Compatible + */ + compatible: MSCompatibleInfoCollection; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + /** + * Fires when the user presses the F1 key while the browser is the active window. + * @param ev The event. + */ + onhelp: (ev: Event) => any; + /** + * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. + * @param ev The drag event. + */ + ondragleave: (ev: DragEvent) => any; + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + /** + * Fires for an element just prior to setting focus on that element. + * @param ev The focus event + */ + onfocusin: (ev: FocusEvent) => any; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + security: string; + /** + * Contains the title of the document. + */ + title: string; + /** + * Retrieves a collection of namespace objects. + */ + namespaces: MSNamespaceInfoCollection; + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + /** + * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. + */ + frames: Window; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + /** + * Fires when the data set exposed by a data source object changes. + * @param ev The event. + */ + ondatasetchanged: (ev: MSEventObj) => any; + /** + * Fires when rows are about to be deleted from the recordset. + * @param ev The event + */ + onrowsdelete: (ev: MSEventObj) => any; + Script: MSScriptHost; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + defaultView: Window; + /** + * Fires when the user is about to make a control selection of the object. + * @param ev The event. + */ + oncontrolselect: (ev: MSEventObj) => any; + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + /** + * Retrieves an autogenerated, unique identifier for the object. + */ + uniqueID: string; + /** + * Sets or gets the URL for the current document. + */ + URL: string; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + /** + * Retrieves the document compatibility mode of the document. + */ + documentMode: number; + characterSet: string; + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + onbeforeupdate: (ev: MSEventObj) => any; + /** + * Fires to indicate that all data is available from the data source object. + * @param ev The event. + */ + ondatasetcomplete: (ev: MSEventObj) => any; + plugins: HTMLCollection; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + /** + * Fires on a databound object when an error occurs while updating the associated data in the data source object. + * @param ev The event. + */ + onerrorupdate: (ev: MSEventObj) => any; + /** + * Gets a reference to the container object of the window. + */ + parentWindow: Window; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + /** + * Fires when data changes in the data provider. + * @param ev The event. + */ + oncellchange: (ev: MSEventObj) => any; + /** + * Fires just before the data source control changes the current row in the object. + * @param ev The event. + */ + onrowexit: (ev: MSEventObj) => any; + /** + * Fires just after new rows are inserted in the current recordset. + * @param ev The event. + */ + onrowsinserted: (ev: MSEventObj) => any; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + msCapsLockWarningOff: boolean; + /** + * Fires when a property changes on the object. + * @param ev The event. + */ + onpropertychange: (ev: MSEventObj) => any; + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + /** + * Sets or gets the security domain of the document. + */ + domain: string; + xmlStandalone: boolean; + /** + * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. + */ + selection: MSSelection; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + /** + * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. + * @param ev The event. + */ + onbeforeeditfocus: (ev: MSEventObj) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: ProgressEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: MouseEvent) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + media: string; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: ErrorEvent) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + /** + * Contains information about the current URL. + */ + location: Location; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: UIEvent) => any; + /** + * Fires for the current element with focus immediately after moving focus to another element. + * @param ev The event. + */ + onfocusout: (ev: FocusEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; + /** + * Fires when a local DOM Storage area is written to disk. + * @param ev The event. + */ + onstoragecommit: (ev: StorageEvent) => any; + /** + * Fires periodically as data arrives from data source objects that asynchronously transmit their data. + * @param ev The event. + */ + ondataavailable: (ev: MSEventObj) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: Event) => any; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + /** + * Fires to indicate that the current row has changed in the data source and new data values are available on the object. + * @param ev The event. + */ + onrowenter: (ev: MSEventObj) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + oninput: (ev: Event) => any; + onmspointerdown: (ev: any) => any; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmscontentzoom: (ev: MSEventObj) => any; + onmspointermove: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + hidden: boolean; + onmspointerup: (ev: any) => any; + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + onmspointerenter: (ev: any) => any; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + onmspointerleave: (ev: any) => any; + /** + * 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; + /** + * 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; + adoptNode(source: Node): Node; + /** + * 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; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + /** + * 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; + /** + * 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; + createCDATASection(data: string): CDATASection; + /** + * 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; + /** + * 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; + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + createElement(tagName: "abbr"): HTMLPhraseElement; + createElement(tagName: "acronym"): HTMLPhraseElement; + createElement(tagName: "address"): HTMLBlockElement; + createElement(tagName: "applet"): HTMLAppletElement; + createElement(tagName: "area"): HTMLAreaElement; + createElement(tagName: "article"): HTMLElement; + createElement(tagName: "aside"): HTMLElement; + createElement(tagName: "audio"): HTMLAudioElement; + createElement(tagName: "b"): HTMLPhraseElement; + createElement(tagName: "base"): HTMLBaseElement; + createElement(tagName: "basefont"): HTMLBaseFontElement; + createElement(tagName: "bdo"): HTMLPhraseElement; + createElement(tagName: "bgsound"): HTMLBGSoundElement; + createElement(tagName: "big"): HTMLPhraseElement; + createElement(tagName: "blockquote"): HTMLBlockElement; + createElement(tagName: "body"): HTMLBodyElement; + createElement(tagName: "br"): HTMLBRElement; + createElement(tagName: "button"): HTMLButtonElement; + createElement(tagName: "canvas"): HTMLCanvasElement; + createElement(tagName: "caption"): HTMLTableCaptionElement; + createElement(tagName: "center"): HTMLBlockElement; + createElement(tagName: "cite"): HTMLPhraseElement; + createElement(tagName: "code"): HTMLPhraseElement; + createElement(tagName: "col"): HTMLTableColElement; + createElement(tagName: "colgroup"): HTMLTableColElement; + createElement(tagName: "datalist"): HTMLDataListElement; + createElement(tagName: "dd"): HTMLDDElement; + createElement(tagName: "del"): HTMLModElement; + createElement(tagName: "dfn"): HTMLPhraseElement; + createElement(tagName: "dir"): HTMLDirectoryElement; + createElement(tagName: "div"): HTMLDivElement; + createElement(tagName: "dl"): HTMLDListElement; + createElement(tagName: "dt"): HTMLDTElement; + createElement(tagName: "em"): HTMLPhraseElement; + createElement(tagName: "embed"): HTMLEmbedElement; + createElement(tagName: "fieldset"): HTMLFieldSetElement; + createElement(tagName: "figcaption"): HTMLElement; + createElement(tagName: "figure"): HTMLElement; + createElement(tagName: "font"): HTMLFontElement; + createElement(tagName: "footer"): HTMLElement; + createElement(tagName: "form"): HTMLFormElement; + createElement(tagName: "frame"): HTMLFrameElement; + createElement(tagName: "frameset"): HTMLFrameSetElement; + createElement(tagName: "h1"): HTMLHeadingElement; + createElement(tagName: "h2"): HTMLHeadingElement; + createElement(tagName: "h3"): HTMLHeadingElement; + createElement(tagName: "h4"): HTMLHeadingElement; + createElement(tagName: "h5"): HTMLHeadingElement; + createElement(tagName: "h6"): HTMLHeadingElement; + createElement(tagName: "head"): HTMLHeadElement; + createElement(tagName: "header"): HTMLElement; + createElement(tagName: "hgroup"): HTMLElement; + createElement(tagName: "hr"): HTMLHRElement; + createElement(tagName: "html"): HTMLHtmlElement; + createElement(tagName: "i"): HTMLPhraseElement; + createElement(tagName: "iframe"): HTMLIFrameElement; + createElement(tagName: "img"): HTMLImageElement; + createElement(tagName: "input"): HTMLInputElement; + createElement(tagName: "ins"): HTMLModElement; + createElement(tagName: "isindex"): HTMLIsIndexElement; + createElement(tagName: "kbd"): HTMLPhraseElement; + createElement(tagName: "keygen"): HTMLBlockElement; + createElement(tagName: "label"): HTMLLabelElement; + createElement(tagName: "legend"): HTMLLegendElement; + createElement(tagName: "li"): HTMLLIElement; + createElement(tagName: "link"): HTMLLinkElement; + createElement(tagName: "listing"): HTMLBlockElement; + createElement(tagName: "map"): HTMLMapElement; + createElement(tagName: "mark"): HTMLElement; + createElement(tagName: "marquee"): HTMLMarqueeElement; + createElement(tagName: "menu"): HTMLMenuElement; + createElement(tagName: "meta"): HTMLMetaElement; + createElement(tagName: "nav"): HTMLElement; + createElement(tagName: "nextid"): HTMLNextIdElement; + createElement(tagName: "nobr"): HTMLPhraseElement; + createElement(tagName: "noframes"): HTMLElement; + createElement(tagName: "noscript"): HTMLElement; + createElement(tagName: "object"): HTMLObjectElement; + createElement(tagName: "ol"): HTMLOListElement; + createElement(tagName: "optgroup"): HTMLOptGroupElement; + createElement(tagName: "option"): HTMLOptionElement; + createElement(tagName: "p"): HTMLParagraphElement; + createElement(tagName: "param"): HTMLParamElement; + createElement(tagName: "plaintext"): HTMLBlockElement; + createElement(tagName: "pre"): HTMLPreElement; + createElement(tagName: "progress"): HTMLProgressElement; + createElement(tagName: "q"): HTMLQuoteElement; + createElement(tagName: "rt"): HTMLPhraseElement; + createElement(tagName: "ruby"): HTMLPhraseElement; + createElement(tagName: "s"): HTMLPhraseElement; + createElement(tagName: "samp"): HTMLPhraseElement; + createElement(tagName: "script"): HTMLScriptElement; + createElement(tagName: "section"): HTMLElement; + createElement(tagName: "select"): HTMLSelectElement; + createElement(tagName: "small"): HTMLPhraseElement; + createElement(tagName: "SOURCE"): HTMLSourceElement; + createElement(tagName: "span"): HTMLSpanElement; + createElement(tagName: "strike"): HTMLPhraseElement; + createElement(tagName: "strong"): HTMLPhraseElement; + createElement(tagName: "style"): HTMLStyleElement; + createElement(tagName: "sub"): HTMLPhraseElement; + createElement(tagName: "sup"): HTMLPhraseElement; + createElement(tagName: "table"): HTMLTableElement; + createElement(tagName: "tbody"): HTMLTableSectionElement; + createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "textarea"): HTMLTextAreaElement; + createElement(tagName: "tfoot"): HTMLTableSectionElement; + createElement(tagName: "th"): HTMLTableHeaderCellElement; + createElement(tagName: "thead"): HTMLTableSectionElement; + createElement(tagName: "title"): HTMLTitleElement; + createElement(tagName: "tr"): HTMLTableRowElement; + createElement(tagName: "track"): HTMLTrackElement; + createElement(tagName: "tt"): HTMLPhraseElement; + createElement(tagName: "u"): HTMLPhraseElement; + createElement(tagName: "ul"): HTMLUListElement; + createElement(tagName: "var"): HTMLPhraseElement; + createElement(tagName: "video"): HTMLVideoElement; + createElement(tagName: "wbr"): HTMLElement; + createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; + createElement(tagName: "xmp"): HTMLBlockElement; + createElement(tagName: string): HTMLElement; + /** + * Removes mouse capture from the object in the current document. + */ + releaseCapture(): 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; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + /** + * 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): any; + /** + * 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; + /** + * 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; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + /** + * 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; + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + /** + * Fires a specified event on the object. + * @param eventName Specifies the name of the event to fire. + * @param eventObj Object that specifies the event object from which to obtain event object properties. + */ + fireEvent(eventName: string, eventObj?: any): boolean; + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "bgsound"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "SOURCE"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeList; + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + /** + * Creates a style sheet for the document. + * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. + * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. + */ + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + /** + * 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): NodeList; + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + /** + * 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; + /** + * Generates an event object to pass event context information when you use the fireEvent method. + * @param eventObj An object that specifies an existing event object on which to base the new object. + */ + createEventObject(eventObj?: any): MSEventObj; + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; + msExitFullscreen(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Document: { + prototype: Document; + new(): Document; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + profileEnd(): void; + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} +declare var Console: { + prototype: Console; + new(): Console; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: any; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: any; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new(): MSEventObj; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + /** + * 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: "experimental-webgl"): WebGLRenderingContext; + /** + * 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: string, ...args: any[]): any; + /** + * 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; + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; +} +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers, WindowBase64, IDBEnvironment, WindowConsole, GlobalEventHandlers { + ondragend: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + ondragover: (ev: DragEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + ondragleave: (ev: DragEvent) => any; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + onpause: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + top: Window; + onmousedown: (ev: MouseEvent) => any; + onseeked: (ev: Event) => any; + opener: Window; + onclick: (ev: MouseEvent) => any; + innerHeight: number; + onwaiting: (ev: Event) => any; + ononline: (ev: Event) => any; + ondurationchange: (ev: Event) => any; + frames: Window; + onblur: (ev: FocusEvent) => any; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + outerWidth: number; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + innerWidth: number; + onoffline: (ev: Event) => any; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onratechange: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onloadstart: (ev: Event) => any; + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + self: Window; + document: Document; + onprogress: (ev: ProgressEvent) => any; + ondblclick: (ev: MouseEvent) => any; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + onchange: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onplay: (ev: Event) => any; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onreadystatechange: (ev: Event) => any; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + frameElement: Element; + onloadeddata: (ev: Event) => any; + onsuspend: (ev: Event) => any; + window: Window; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onselect: (ev: UIEvent) => any; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onended: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onunload: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + onload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + oninput: (ev: Event) => any; + performance: Performance; + onmspointerdown: (ev: any) => any; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + onmspointerover: (ev: any) => any; + onpopstate: (ev: PopStateEvent) => any; + onmspointerup: (ev: any) => any; + onpageshow: (ev: PageTransitionEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + doNotTrack: string; + onmspointerenter: (ev: any) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onmspointerleave: (ev: any) => any; + alert(message?: any): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, _default?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Window: { + prototype: Window; + new(): Window; +} + +interface HTMLCollection extends MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + // [name: string]: Element; + [index: number]: Element; +} +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface Blob { + type: string; + size: number; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; + msClose(): void; +} +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface NavigatorID { + appVersion: string; + appName: string; + userAgent: string; + platform: string; + product: string; + vendor: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Retrieves a collection of all cells in the table row or in the entire table. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * 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 width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * 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 an empty tBody element in the table. + */ + createTBody(): HTMLElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): 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): HTMLElement; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLElement; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLElement; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): any; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new(): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new(): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new(): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; + now(): number; +} +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new(): CompositionEvent; +} + +interface WindowTimers extends WindowTimersExtension { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + touchAction: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new(): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils, MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + pointerEnabled: boolean; + maxTouchPoints: number; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new(): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new(): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new(): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new(): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface Element extends Node, NodeSelector, ElementTraversal, GlobalEventHandlers { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + onmsgotpointercapture: (ev: any) => any; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + onmslostpointercapture: (ev: any) => any; + onmspointerover: (ev: any) => any; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + onlostpointercapture: (ev: PointerEvent) => any; + onmspointerenter: (ev: any) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onmspointerleave: (ev: any) => any; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "bgsound"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "SOURCE"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeList; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; + msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; + msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; + msRequestFullscreen(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Element: { + prototype: Element; + new(): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new(): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new(): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new(): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Removes an element from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new(): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new(): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new(): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new(): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + name: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new(): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the shape of the object. + */ + name: 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 URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new(): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: "AnimationEvent"): AnimationEvent; + createEvent(eventInterface: "CloseEvent"): CloseEvent; + createEvent(eventInterface: "CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; + createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; + createEvent(eventInterface: "DragEvent"): DragEvent; + createEvent(eventInterface: "ErrorEvent"): ErrorEvent; + createEvent(eventInterface: "Event"): Event; + createEvent(eventInterface: "Events"): Event; + createEvent(eventInterface: "FocusEvent"): FocusEvent; + createEvent(eventInterface: "HTMLEvents"): Event; + createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface: "LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; + createEvent(eventInterface: "MessageEvent"): MessageEvent; + createEvent(eventInterface: "MouseEvent"): MouseEvent; + createEvent(eventInterface: "MouseEvents"): MouseEvent; + createEvent(eventInterface: "MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface: "MSPointerEvent"): MSPointerEvent; + createEvent(eventInterface: "MutationEvent"): MutationEvent; + createEvent(eventInterface: "MutationEvents"): MutationEvent; + createEvent(eventInterface: "NavigationCompletedEvent"): NavigationCompletedEvent; + createEvent(eventInterface: "NavigationEvent"): NavigationEvent; + createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface: "PointerEvent"): MSPointerEvent; + createEvent(eventInterface: "PopStateEvent"): PopStateEvent; + createEvent(eventInterface: "ProgressEvent"): ProgressEvent; + createEvent(eventInterface: "StorageEvent"): StorageEvent; + createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface: "TextEvent"): TextEvent; + 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 HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * The starting number. + */ + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new(): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new(): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new(): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * 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; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * 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; + /** + * 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?: any): void; + /** + * 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; + [name: string]: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new(): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new(): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new(): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new(): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new(): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * 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; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: 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 character set used to encode the object. + */ + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new(): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new(): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: any; + namedRecordset(dataMember: string, hierarchy?: any): any; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new(): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new(): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + name: string; + readyState: string; + doImport(implementationUrl: string): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new(): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new(): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * 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; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; + create(): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new(): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new(): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new(): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new(): MSCSSProperties; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Contains the hypertext reference (HREF) of the URL. + */ + href: string; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + crossOrigin: string; + msPlayToPreferredSourceUri: string; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): HTMLImageElement; + create(): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: 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 shape of the object. + */ + shape: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface EventTarget { + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: 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; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * 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; + /** + * 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; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new(): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; + msKeySystem: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + ports: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new(): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onfocusin: (ev: FocusEvent) => any; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + onload: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + id: string; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; + async: boolean; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new(): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * 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): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new(): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): number[]; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: number[]): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new(): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new(): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new(): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new(): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new(): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new(): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: 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 border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new(): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: any; + ontimeout: (ev: Event) => any; + statusText: string; + onreadystatechange: (ev: Event) => any; + timeout: number; + onload: (ev: Event) => any; + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: UIEvent) => any; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + onloadstart: (ev: Event) => any; + msCaching: string; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + create(): XMLHttpRequest; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new(): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new(): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + onerror: (ev: ErrorEvent) => any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + onresize: (ev: UIEvent) => any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + border: string; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onstorage: (ev: StorageEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new(): HTMLFrameSetElement; +} + +interface Screen extends EventTarget { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; + msOrientation: string; + onmsorientationchange: (ev: any) => any; + msLockOrientation(orientation: string): boolean; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + types: DOMStringList; + files: FileList; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new(): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + createContextualFragment(fragment: string): DocumentFragment; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new(): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new(): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new(): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: ErrorEvent) => any; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + currentScale: number; + onscroll: (ev: UIEvent) => any; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new(): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new(): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new(): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new(): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new(): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): any; + tags(tagName: any): any; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: string; +} +declare var Storage: { + prototype: Storage; + new(): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: 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 amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * 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 the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + sandbox: DOMSettableTokenList; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new(): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new(): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + onblur: (ev: FocusEvent) => any; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + text: any; + onerror: (ev: ErrorEvent) => any; + bgProperties: string; + onresize: (ev: UIEvent) => any; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + vLink: any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + onpopstate: (ev: PopStateEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; + createTextRange(): TextRange; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new(): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new(): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} +declare var DragEvent: { + prototype: DragEvent; + new(): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): any; + /** + * 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): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + status: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. + */ + vrml: string; + /** + * Sets or retrieves a lower resolution image to display. + */ + lowsrc: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: 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 height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + dynsrc: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + start: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * 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; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: 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; + /** + * 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; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * 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; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * 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; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * 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; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * 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; + /** + * Makes the selection equal to the current object. + */ + select(): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + Methods: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + protocolLong: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + nameProp: string; + urn: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + type: string; + mimeType: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new(): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * 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 data type of the value attribute. + */ + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + name: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new(): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new(): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new(): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new(): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + ontimeout: (ev: Event) => any; + responseText: string; + contentType: string; + open(method: string, url: string): void; + abort(): void; + send(data?: any): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new(): XDomainRequest; + create(): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new(): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new(): SVGPathSegCurvetoCubicRel; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new(): Location; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new(): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new(): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new(): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + 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; + getCurrentPoint(element: Element): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new(): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new(): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new(): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new(): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new(): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: 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 abbreviated text for the object. + */ + abbr: string; + /** + * 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 color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new(): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): any; + item(index: any): any; + // [index: any]: any; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new(): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new(): CustomEvent; +} + +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; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * 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; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * 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; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * 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; + /** + * Highlights the input area of a form element. + */ + select(): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +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 DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + onfinish: (ev: Event) => any; + stop(): void; + start(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new(): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + state: any; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} +declare var History: { + prototype: History; + new(): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new(): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new(): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new(): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new(): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new(): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new(): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new(): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: number[]; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new(): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * 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; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + name: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new(): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +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 how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + // [name: string]: Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new(): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new(): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new(): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new(): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; + captureEvents(): void; + releaseEvents(): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new(): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: Date; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new(): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new(): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new(): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new(): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + language: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * 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 encoding type for the form. + */ + enctype: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * 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; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + [name: string]: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: SVGZoomAndPan; + +interface HTMLMediaElement extends HTMLElement { + /** + * Gets the earliest possible position, in seconds, that the playback can begin. + */ + initialTime: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + readyState: any; + /** + * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. + */ + autobuffer: boolean; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * 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; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: 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; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + /** + * Gets the current network activity for the element. + */ + networkState: number; + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + textTracks: TextTrackList; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + /** + * 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; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + /** + * 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; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new(): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new(): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new(): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new(): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new(): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: NodeFilter; + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new(): SVGNumberList; +} + +interface MediaError { + code: number; + msExtendedCode: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new(): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + /** + * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. + */ + balance: any; + /** + * Sets or gets the volume setting for the sound. + */ + volume: any; + /** + * Sets or gets the URL of a sound to play. + */ + src: string; + /** + * Sets or retrieves the number of times a sound or video clip will loop when activated. + */ + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new(): HTMLBGSoundElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * 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; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the contained object. + */ + object: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the name of the object. + */ + name: 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 URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + declare: boolean; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * 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 or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + readyState: number; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new(): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + hidden: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; + /** + * 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 or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + readyState: string; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new(): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new(): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: 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; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * 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; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new(): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new(): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new(): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + name: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new(): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: any; + namedRecordset(dataMember: string, hierarchy?: any): any; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the width of the video element. + */ + width: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets or sets the height of the video element. + */ + height: number; + /** + * 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; + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + onMSVideoFrameStepCompleted: (ev: any) => any; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; + getVideoPlaybackQuality(): VideoPlaybackQuality; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new(): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new(): External; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface ErrorEvent extends Event { + colno: number; + filename: string; + error: any; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} +declare var ErrorEvent: { + prototype: ErrorEvent; + new(): ErrorEvent; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface TrackEvent extends Event { + track: any; +} +declare var TrackEvent: { + prototype: TrackEvent; + new(): TrackEvent; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + getCueAsHTML(): DocumentFragment; + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new(startTime: number, endTime: number, text: string): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(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; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var DOMTokenList: { + prototype: DOMTokenList; + new(): DOMTokenList; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} +declare var TransitionEvent: { + prototype: TransitionEvent; + new(): TransitionEvent; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface DOMError { + name: string; + toString(): string; +} +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} +declare var CloseEvent: { + prototype: CloseEvent; + new(): CloseEvent; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + extensions: string; + onmessage: (ev: MessageEvent) => any; + onclose: (ev: CloseEvent) => any; + onerror: (ev: ErrorEvent) => any; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string): WebSocket; + new(url: string, protocols?: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} +declare var ProgressEvent: { + prototype: ProgressEvent; + new(): ProgressEvent; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} +declare var File: { + prototype: File; + new(): File; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + ontimeout: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onloadstart: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XMLHttpRequestEventTarget: { + prototype: XMLHttpRequestEventTarget; + new(): XMLHttpRequestEventTarget; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: Event) => any; + onaddtrack: (ev: TrackEvent) => any; + onremovetrack: (ev: any /*PluginArray*/) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: any /*PluginArray*/) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + readyState: number; + onabort: (ev: UIEvent) => any; + onloadend: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + onloadstart: (ev: Event) => any; + result: any; + abort(): void; + LOADING: number; + EMPTY: number; + DONE: number; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} +declare var AnimationEvent: { + prototype: AnimationEvent; + new(): AnimationEvent; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; +} +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: UIEvent) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; + sourceBuffer: SourceBuffer; +} +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} +declare var CSSKeyframesRule: { + prototype: CSSKeyframesRule; + new(): CSSKeyframesRule; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + item(index: number): TextTrack; + [index: number]: TextTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: UIEvent) => any; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBDatabase: { + prototype: IDBDatabase; + new(): IDBDatabase; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + onblocked: (ev: Event) => any; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * 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; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + kind: string; + onload: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + label: string; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + readyState: string; + result: any; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + oncached: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onchecking: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + swapCache(): void; + abort(): void; + update(): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} +declare var PopStateEvent: { + prototype: PopStateEvent; + new(): PopStateEvent; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} +declare var DOMSettableTokenList: { + prototype: DOMSettableTokenList; + new(): DOMSettableTokenList; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} +declare var IDBFactory: { + prototype: IDBFactory; + new(): IDBFactory; +} + +interface MSPointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + 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; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + prototype: MSPointerEvent; + new(): MSPointerEvent; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} +declare var FormData: { + prototype: FormData; + new(): FormData; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; + readyState: number; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; +} +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +declare var MSApp: MSApp; + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new(text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: MessageEvent) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Worker: { + prototype: Worker; + new(stringUrl: string): Worker; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface VideoPlaybackQuality { + totalFrameDelay: number; + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface GlobalEventHandlers { + onpointerenter: (ev: PointerEvent) => any; + onpointerout: (ev: PointerEvent) => any; + onpointerdown: (ev: PointerEvent) => any; + onpointerup: (ev: PointerEvent) => any; + onpointercancel: (ev: PointerEvent) => any; + onpointerover: (ev: PointerEvent) => any; + onpointermove: (ev: PointerEvent) => any; + onpointerleave: (ev: PointerEvent) => any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} +declare var Key: { + prototype: Key; + new(): Key; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; + // [name: string]: Element; +} +declare var HTMLAllCollection: { + prototype: HTMLAllCollection; + new(): HTMLAllCollection; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} +declare var AesGcmEncryptResult: { + prototype: AesGcmEncryptResult; + new(): AesGcmEncryptResult; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; + // [type: string]: Plugin; +} +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + result: any; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var KeyOperation: { + prototype: KeyOperation; + new(): KeyOperation; +} + +interface DOMStringMap { +} +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(): DeviceOrientationEvent; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new(keySystem: string): MSMediaKeys; + isTypeSupported(keySystem: string, type?: string): boolean; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface NavigationEvent extends Event { + uri: string; +} +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SourceBuffer extends EventTarget { + updating: boolean; + appendWindowStart: number; + appendWindowEnd: number; + buffered: TimeRanges; + timestampOffset: number; + audioTracks: AudioTrackList; + appendBuffer(data: ArrayBuffer): void; + remove(start: number, end: number): void; + abort(): void; + appendStream(stream: MSStream, maxSize?: number): void; +} +declare var SourceBuffer: { + prototype: SourceBuffer; + new(): SourceBuffer; +} + +interface MSInputMethodContext extends EventTarget { + oncandidatewindowshow: (ev: any) => any; + target: HTMLElement; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + oncandidatewindowupdate: (ev: any) => any; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; + // [name: string]: Plugin; +} +declare var PluginArray: { + prototype: PluginArray; + new(): PluginArray; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; + // [type: string]: MimeType; +} +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: number; + readyState: string; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new(): MediaSource; + isTypeSupported(type: string): boolean; +} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface XMLDocument extends Document { +} +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(): DeviceMotionEvent; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface PointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + 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; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; +} +declare var PointerEvent: { + prototype: PointerEvent; + new(): PointerEvent; +} + +interface MSDocumentExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: Event) => any; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + readyState: number; + type: number; + result: any; + start(): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} +declare var LongRunningScriptDetectedEvent: { + prototype: LongRunningScriptDetectedEvent; + new(): LongRunningScriptDetectedEvent; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} +declare var MSAppView: { + prototype: MSAppView; + new(): MSAppView; +} + +interface PerfWidgetExternal { + maxCpuSpeed: number; + independentRenderingEnabled: boolean; + irDisablingContentString: string; + irStatusAvailable: boolean; + performanceCounter: number; + averagePaintTime: number; + activeNetworkRequestCount: number; + paintRequestsPerSecond: number; + extraInformationEnabled: boolean; + performanceCounterFrequency: number; + averageFrameTime: number; + repositionWindow(x: number, y: number): void; + getRecentMemoryUsage(last: number): any; + getMemoryUsage(): number; + resizeWindow(width: number, height: number): void; + getProcessCpuUsage(): number; + removeEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentCpuUsage(last: number): any; + addEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentFrames(last: number): any; + getRecentPaintRequests(last: number): any; +} +declare var PerfWidgetExternal: { + prototype: PerfWidgetExternal; + new(): PerfWidgetExternal; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} +declare var KeyPair: { + prototype: KeyPair; + new(): KeyPair; +} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: UIEvent) => any; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var CryptoOperation: { + prototype: CryptoOperation; + new(): CryptoOperation; +} + +interface WebGLTexture extends WebGLObject { +} +declare var WebGLTexture: { + prototype: WebGLTexture; + new(): WebGLTexture; +} + +interface OES_texture_float { +} +declare var OES_texture_float: { + prototype: OES_texture_float; + new(): OES_texture_float; +} + +interface WebGLContextEvent extends Event { + statusMessage: string; +} +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(): WebGLContextEvent; +} + +interface WebGLRenderbuffer extends WebGLObject { +} +declare var WebGLRenderbuffer: { + prototype: WebGLRenderbuffer; + new(): WebGLRenderbuffer; +} + +interface WebGLUniformLocation { +} +declare var WebGLUniformLocation: { + prototype: WebGLUniformLocation; + new(): WebGLUniformLocation; +} + +interface WebGLActiveInfo { + name: string; + type: number; + size: number; +} +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WEBGL_compressed_texture_s3tc { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WebGLRenderingContext { + drawingBufferWidth: number; + drawingBufferHeight: number; + canvas: HTMLCanvasElement; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + bindTexture(target: number, texture: WebGLTexture): void; + bufferData(target: number, data: ArrayBufferView, usage: number): void; + bufferData(target: number, data: ArrayBuffer, usage: number): void; + bufferData(target: number, size: number, usage: number): void; + depthMask(flag: boolean): void; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + vertexAttrib3fv(indx: number, values: number[]): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; + linkProgram(program: WebGLProgram): void; + getSupportedExtensions(): string[]; + bufferSubData(target: number, offset: number, data: ArrayBuffer): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + polygonOffset(factor: number, units: number): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + createTexture(): WebGLTexture; + hint(target: number, mode: number): void; + getVertexAttrib(index: number, pname: number): any; + enableVertexAttribArray(index: number): void; + depthRange(zNear: number, zFar: number): void; + cullFace(mode: number): void; + createFramebuffer(): WebGLFramebuffer; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + getExtension(name: string): any; + createProgram(): WebGLProgram; + deleteShader(shader: WebGLShader): void; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + enable(cap: number): void; + blendEquation(mode: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + createBuffer(): WebGLBuffer; + deleteTexture(texture: WebGLTexture): void; + useProgram(program: WebGLProgram): void; + vertexAttrib2fv(indx: number, values: number[]): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + checkFramebufferStatus(target: number): number; + frontFace(mode: number): void; + getBufferParameter(target: number, pname: number): any; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + getVertexAttribOffset(index: number, pname: number): number; + disableVertexAttribArray(index: number): void; + blendFunc(sfactor: number, dfactor: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + uniform3iv(location: WebGLUniformLocation, v: number[]): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + lineWidth(width: number): void; + getShaderInfoLog(shader: WebGLShader): string; + getTexParameter(target: number, pname: number): any; + getParameter(pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getContextAttributes(): WebGLContextAttributes; + vertexAttrib1f(indx: number, x: number): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + isContextLost(): boolean; + uniform1iv(location: WebGLUniformLocation, v: number[]): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + getRenderbufferParameter(target: number, pname: number): any; + uniform2fv(location: WebGLUniformLocation, v: number[]): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + isTexture(texture: WebGLTexture): boolean; + getError(): number; + shaderSource(shader: WebGLShader, source: string): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + stencilMask(mask: number): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + getAttribLocation(program: WebGLProgram, name: string): number; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + clear(mask: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + scissor(x: number, y: number, width: number, height: number): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getShaderSource(shader: WebGLShader): string; + generateMipmap(target: number): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + uniform1fv(location: WebGLUniformLocation, v: number[]): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2iv(location: WebGLUniformLocation, v: number[]): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + uniform4fv(location: WebGLUniformLocation, v: number[]): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + vertexAttrib1fv(indx: number, values: number[]): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + flush(): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + deleteProgram(program: WebGLProgram): void; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + uniform1i(location: WebGLUniformLocation, x: number): void; + getProgramParameter(program: WebGLProgram, pname: number): any; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + stencilFunc(func: number, ref: number, mask: number): void; + pixelStorei(pname: number, param: number): void; + disable(cap: number): void; + vertexAttrib4fv(indx: number, values: number[]): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + createRenderbuffer(): WebGLRenderbuffer; + isBuffer(buffer: WebGLBuffer): boolean; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + sampleCoverage(value: number, invert: boolean): void; + depthFunc(func: number): void; + texParameterf(target: number, pname: number, param: number): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + drawArrays(mode: number, first: number, count: number): void; + texParameteri(target: number, pname: number, param: number): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + getShaderParameter(shader: WebGLShader, pname: number): any; + clearDepth(depth: number): void; + activeTexture(texture: number): void; + viewport(x: number, y: number, width: number, height: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + uniform1f(location: WebGLUniformLocation, x: number): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + deleteBuffer(buffer: WebGLBuffer): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + uniform3fv(location: WebGLUniformLocation, v: number[]): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + stencilMaskSeparate(face: number, mask: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + compileShader(shader: WebGLShader): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + isShader(shader: WebGLShader): boolean; + clearStencil(s: number): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + finish(): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + getProgramInfoLog(program: WebGLProgram): string; + validateProgram(program: WebGLProgram): void; + isEnabled(cap: number): boolean; + vertexAttrib2f(indx: number, x: number, y: number): void; + isProgram(program: WebGLProgram): boolean; + createShader(type: number): WebGLShader; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + uniform4iv(location: WebGLUniformLocation, v: number[]): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} + +interface WebGLProgram extends WebGLObject { +} +declare var WebGLProgram: { + prototype: WebGLProgram; + new(): WebGLProgram; +} + +interface OES_standard_derivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface WebGLFramebuffer extends WebGLObject { +} +declare var WebGLFramebuffer: { + prototype: WebGLFramebuffer; + new(): WebGLFramebuffer; +} + +interface WebGLShader extends WebGLObject { +} +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface OES_texture_float_linear { +} +declare var OES_texture_float_linear: { + prototype: OES_texture_float_linear; + new(): OES_texture_float_linear; +} + +interface WebGLObject { +} +declare var WebGLObject: { + prototype: WebGLObject; + new(): WebGLObject; +} + +interface WebGLBuffer extends WebGLObject { +} +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLShaderPrecisionFormat { + rangeMin: number; + rangeMax: number; + precision: number; +} +declare var WebGLShaderPrecisionFormat: { + prototype: WebGLShaderPrecisionFormat; + new(): WebGLShaderPrecisionFormat; +} + +interface EXT_texture_filter_anisotropic { + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var Option: { new(text?: string, value?: string, defaultSelected?: boolean, selected?:boolean): HTMLOptionElement; }; +declare var Image: { new(width?: number, height?: number): HTMLImageElement; }; +declare var Audio: { new(src?: string): HTMLAudioElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare var onpause: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var ondurationchange: (ev: Event) => any; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare var onemptied: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var oncanplay: (ev: Event) => any; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onloadstart: (ev: Event) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: ProgressEvent) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare var onchange: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare var onabort: (ev: UIEvent) => any; +declare var onreadystatechange: (ev: Event) => any; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onselect: (ev: UIEvent) => any; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onended: (ev: Event) => any; +declare var onhashchange: (ev: Event) => any; +declare var onunload: (ev: Event) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var oninput: (ev: Event) => any; +declare var performance: Performance; +declare var onmspointerdown: (ev: any) => any; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare var onmspointerhover: (ev: any) => any; +declare var onmsgesturehold: (ev: any) => any; +declare var onmspointermove: (ev: any) => any; +declare var onmsgesturechange: (ev: any) => any; +declare var onmsgesturestart: (ev: any) => any; +declare var onmspointercancel: (ev: any) => any; +declare var onmsgestureend: (ev: any) => any; +declare var onmsgesturetap: (ev: any) => any; +declare var onmspointerout: (ev: any) => any; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare var onmspointerover: (ev: any) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onmspointerup: (ev: any) => any; +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var doNotTrack: string; +declare var onmspointerenter: (ev: any) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +declare var onmspointerleave: (ev: any) => any; +declare function alert(message?: any): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare function captureEvents(): void; +declare function releaseEvents(): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function msSetImmediate(expression: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function msClearImmediate(handle: number): void; +declare function setImmediate(expression: any, ...args: any[]): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; +declare var onpointerenter: (ev: PointerEvent) => any; +declare var onpointerout: (ev: PointerEvent) => any; +declare var onpointerdown: (ev: PointerEvent) => any; +declare var onpointerup: (ev: PointerEvent) => any; +declare var onpointercancel: (ev: PointerEvent) => any; +declare var onpointerover: (ev: PointerEvent) => any; +declare var onpointermove: (ev: PointerEvent) => any; +declare var onpointerleave: (ev: PointerEvent) => any; +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// These are only available in a Web Worker +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// + +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index 8675d267aa4..eefa7a42014 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -647,6 +647,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -658,6 +659,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -670,10 +672,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/tsc.js b/bin/tsc.js index c1ce8cee83d..ff98a7db289 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -34,15 +34,15 @@ var ts; var ts; (function (ts) { function forEach(array, callback) { - var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) { - break; + var result = callback(array[i]); + if (result) { + return result; } } } - return result; + return undefined; } ts.forEach = forEach; function contains(array, value) { @@ -521,24 +521,34 @@ var ts; return path; } ts.removeFileExtension = removeFileExtension; - var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\0-\19\t\v\f\b\0\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = { + "\0": "\\0", "\t": "\\t", "\v": "\\v", "\f": "\\f", "\b": "\\b", - "\0": "\\0", "\r": "\\r", "\n": "\\n", + "\\": "\\\\", "\"": "\\\"", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }; function escapeString(s) { - return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { - return escapedCharsMap[c] || c; - }) : s; + s = backslashOrDoubleQuote.test(s) ? s.replace(backslashOrDoubleQuote, getReplacement) : s; + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || unicodeEscape(c); + } + function unicodeEscape(c) { + var hexCharCode = c.charCodeAt(0).toString(16); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } } ts.escapeString = escapeString; function Symbol(flags, name) { @@ -591,201 +601,204 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -var sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - 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; +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + 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); } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; } - 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(); - } - } - return { - 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 (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - exit: function (exitCode) { + fileStream.Open(); try { - WScript.Quit(exitCode); + 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 getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require('os'); - var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - return buffer.toString("utf8", 3); - } - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - if (writeByteOrderMark) { - data = '\uFEFF' + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - _fs.writeSync(1, s); - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); - return { - close: function () { - _fs.unwatchFile(fileName, fileChanged); + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; } - }; - function fileChanged(curr, prev) { - if (+curr.mtime <= +prev.mtime) { - return; + else { + fileStream.Position = 3; } - callback(fileName); + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); } - ; - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); + finally { + binaryStream.Close(); + fileStream.Close(); } - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); - } - else if (typeof module !== "undefined" && module.exports) { - return getNodeSystem(); - } - else { - return undefined; - } -})(); + return { + 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 (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require('os'); + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = '\uFEFF' + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + _fs.writeSync(1, s); + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + function fileChanged(curr, prev) { + if (+curr.mtime <= +prev.mtime) { + return; + } + callback(fileName); + } + ; + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof module !== "undefined" && module.exports) { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); var ts; (function (ts) { ts.Diagnostics = { @@ -893,8 +906,7 @@ var ts; Type_argument_expected: { code: 1140, category: 1 /* Error */, key: "Type argument expected." }, String_literal_expected: { code: 1141, category: 1 /* Error */, key: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: 1 /* Error */, key: "Line break not permitted here." }, - catch_or_finally_expected: { code: 1143, category: 1 /* Error */, key: "'catch' or 'finally' expected." }, - Block_or_expected: { code: 1144, category: 1 /* Error */, key: "Block or ';' expected." }, + or_expected: { code: 1144, category: 1 /* Error */, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1 /* Error */, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: 1 /* Error */, key: "Declaration expected." }, Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1 /* Error */, key: "Import declarations in an internal module cannot reference an external module." }, @@ -907,12 +919,32 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1 /* Error */, key: "Computed property names are not allowed in enums." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: 1 /* Error */, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: 1 /* Error */, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1 /* Error */, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: 1 /* Error */, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: 1 /* Error */, key: "Computed property names are not allowed in interfaces." }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: 1 /* Error */, key: "Computed property names are not allowed in type literals." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1 /* Error */, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: 1 /* Error */, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: 1 /* Error */, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: 1 /* Error */, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: 1 /* Error */, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1 /* Error */, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: 1 /* Error */, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: 1 /* Error */, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: 1 /* Error */, key: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: 1 /* Error */, key: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: 1 /* Error */, key: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: 1 /* Error */, key: "A destructuring declaration must have an initializer." }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: 1 /* Error */, key: "Destructuring declarations are not allowed in ambient contexts." }, + Merge_conflict_marker_encountered: { code: 1184, category: 1 /* Error */, key: "Merge conflict marker encountered." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -1005,8 +1037,6 @@ var ts; Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1 /* Error */, key: "Overload signature is not compatible with function implementation." }, Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1 /* Error */, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1 /* Error */, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: { code: 2397, category: 1 /* Error */, key: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter." }, - Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: { code: 2398, category: 1 /* Error */, key: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1 /* Error */, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1 /* Error */, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1 /* Error */, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, @@ -1062,6 +1092,9 @@ var ts; Type_alias_0_circularly_references_itself: { code: 2456, category: 1 /* Error */, key: "Type alias '{0}' circularly references itself." }, Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1 /* Error */, key: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: 1 /* Error */, key: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: 1 /* Error */, key: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: 1 /* Error */, key: "Type '{0}' is not an array type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1184,6 +1217,7 @@ var ts; Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1 /* Error */, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1 /* Error */, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: 1 /* Error */, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1202,118 +1236,119 @@ var ts; 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: 1 /* Error */, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." }, - generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." } + Generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "Generators are not currently supported." }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: 1 /* Error */, key: "Computed property names are not currently supported." } }; })(ts || (ts = {})); var ts; (function (ts) { var textToToken = { - "any": 109 /* AnyKeyword */, - "boolean": 110 /* BooleanKeyword */, - "break": 64 /* BreakKeyword */, - "case": 65 /* CaseKeyword */, - "catch": 66 /* CatchKeyword */, - "class": 67 /* ClassKeyword */, - "continue": 69 /* ContinueKeyword */, - "const": 68 /* ConstKeyword */, - "constructor": 111 /* ConstructorKeyword */, - "debugger": 70 /* DebuggerKeyword */, - "declare": 112 /* DeclareKeyword */, - "default": 71 /* DefaultKeyword */, - "delete": 72 /* DeleteKeyword */, - "do": 73 /* DoKeyword */, - "else": 74 /* ElseKeyword */, - "enum": 75 /* EnumKeyword */, - "export": 76 /* ExportKeyword */, - "extends": 77 /* ExtendsKeyword */, - "false": 78 /* FalseKeyword */, - "finally": 79 /* FinallyKeyword */, - "for": 80 /* ForKeyword */, - "function": 81 /* FunctionKeyword */, - "get": 113 /* GetKeyword */, - "if": 82 /* IfKeyword */, - "implements": 100 /* ImplementsKeyword */, - "import": 83 /* ImportKeyword */, - "in": 84 /* InKeyword */, - "instanceof": 85 /* InstanceOfKeyword */, - "interface": 101 /* InterfaceKeyword */, - "let": 102 /* LetKeyword */, - "module": 114 /* ModuleKeyword */, - "new": 86 /* NewKeyword */, - "null": 87 /* NullKeyword */, - "number": 116 /* NumberKeyword */, - "package": 103 /* PackageKeyword */, - "private": 104 /* PrivateKeyword */, - "protected": 105 /* ProtectedKeyword */, - "public": 106 /* PublicKeyword */, - "require": 115 /* RequireKeyword */, - "return": 88 /* ReturnKeyword */, - "set": 117 /* SetKeyword */, - "static": 107 /* StaticKeyword */, - "string": 118 /* StringKeyword */, - "super": 89 /* SuperKeyword */, - "switch": 90 /* SwitchKeyword */, - "this": 91 /* ThisKeyword */, - "throw": 92 /* ThrowKeyword */, - "true": 93 /* TrueKeyword */, - "try": 94 /* TryKeyword */, - "type": 119 /* TypeKeyword */, - "typeof": 95 /* TypeOfKeyword */, - "var": 96 /* VarKeyword */, - "void": 97 /* VoidKeyword */, - "while": 98 /* WhileKeyword */, - "with": 99 /* WithKeyword */, - "yield": 108 /* YieldKeyword */, - "{": 13 /* OpenBraceToken */, - "}": 14 /* CloseBraceToken */, - "(": 15 /* OpenParenToken */, - ")": 16 /* CloseParenToken */, - "[": 17 /* OpenBracketToken */, - "]": 18 /* CloseBracketToken */, - ".": 19 /* DotToken */, - "...": 20 /* DotDotDotToken */, - ";": 21 /* SemicolonToken */, - ",": 22 /* CommaToken */, - "<": 23 /* LessThanToken */, - ">": 24 /* GreaterThanToken */, - "<=": 25 /* LessThanEqualsToken */, - ">=": 26 /* GreaterThanEqualsToken */, - "==": 27 /* EqualsEqualsToken */, - "!=": 28 /* ExclamationEqualsToken */, - "===": 29 /* EqualsEqualsEqualsToken */, - "!==": 30 /* ExclamationEqualsEqualsToken */, - "=>": 31 /* EqualsGreaterThanToken */, - "+": 32 /* PlusToken */, - "-": 33 /* MinusToken */, - "*": 34 /* AsteriskToken */, - "/": 35 /* SlashToken */, - "%": 36 /* PercentToken */, - "++": 37 /* PlusPlusToken */, - "--": 38 /* MinusMinusToken */, - "<<": 39 /* LessThanLessThanToken */, - ">>": 40 /* GreaterThanGreaterThanToken */, - ">>>": 41 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 42 /* AmpersandToken */, - "|": 43 /* BarToken */, - "^": 44 /* CaretToken */, - "!": 45 /* ExclamationToken */, - "~": 46 /* TildeToken */, - "&&": 47 /* AmpersandAmpersandToken */, - "||": 48 /* BarBarToken */, - "?": 49 /* QuestionToken */, - ":": 50 /* ColonToken */, - "=": 51 /* EqualsToken */, - "+=": 52 /* PlusEqualsToken */, - "-=": 53 /* MinusEqualsToken */, - "*=": 54 /* AsteriskEqualsToken */, - "/=": 55 /* SlashEqualsToken */, - "%=": 56 /* PercentEqualsToken */, - "<<=": 57 /* LessThanLessThanEqualsToken */, - ">>=": 58 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 60 /* AmpersandEqualsToken */, - "|=": 61 /* BarEqualsToken */, - "^=": 62 /* CaretEqualsToken */ + "any": 110 /* AnyKeyword */, + "boolean": 111 /* BooleanKeyword */, + "break": 65 /* BreakKeyword */, + "case": 66 /* CaseKeyword */, + "catch": 67 /* CatchKeyword */, + "class": 68 /* ClassKeyword */, + "continue": 70 /* ContinueKeyword */, + "const": 69 /* ConstKeyword */, + "constructor": 112 /* ConstructorKeyword */, + "debugger": 71 /* DebuggerKeyword */, + "declare": 113 /* DeclareKeyword */, + "default": 72 /* DefaultKeyword */, + "delete": 73 /* DeleteKeyword */, + "do": 74 /* DoKeyword */, + "else": 75 /* ElseKeyword */, + "enum": 76 /* EnumKeyword */, + "export": 77 /* ExportKeyword */, + "extends": 78 /* ExtendsKeyword */, + "false": 79 /* FalseKeyword */, + "finally": 80 /* FinallyKeyword */, + "for": 81 /* ForKeyword */, + "function": 82 /* FunctionKeyword */, + "get": 114 /* GetKeyword */, + "if": 83 /* IfKeyword */, + "implements": 101 /* ImplementsKeyword */, + "import": 84 /* ImportKeyword */, + "in": 85 /* InKeyword */, + "instanceof": 86 /* InstanceOfKeyword */, + "interface": 102 /* InterfaceKeyword */, + "let": 103 /* LetKeyword */, + "module": 115 /* ModuleKeyword */, + "new": 87 /* NewKeyword */, + "null": 88 /* NullKeyword */, + "number": 117 /* NumberKeyword */, + "package": 104 /* PackageKeyword */, + "private": 105 /* PrivateKeyword */, + "protected": 106 /* ProtectedKeyword */, + "public": 107 /* PublicKeyword */, + "require": 116 /* RequireKeyword */, + "return": 89 /* ReturnKeyword */, + "set": 118 /* SetKeyword */, + "static": 108 /* StaticKeyword */, + "string": 119 /* StringKeyword */, + "super": 90 /* SuperKeyword */, + "switch": 91 /* SwitchKeyword */, + "this": 92 /* ThisKeyword */, + "throw": 93 /* ThrowKeyword */, + "true": 94 /* TrueKeyword */, + "try": 95 /* TryKeyword */, + "type": 120 /* TypeKeyword */, + "typeof": 96 /* TypeOfKeyword */, + "var": 97 /* VarKeyword */, + "void": 98 /* VoidKeyword */, + "while": 99 /* WhileKeyword */, + "with": 100 /* WithKeyword */, + "yield": 109 /* YieldKeyword */, + "{": 14 /* OpenBraceToken */, + "}": 15 /* CloseBraceToken */, + "(": 16 /* OpenParenToken */, + ")": 17 /* CloseParenToken */, + "[": 18 /* OpenBracketToken */, + "]": 19 /* CloseBracketToken */, + ".": 20 /* DotToken */, + "...": 21 /* DotDotDotToken */, + ";": 22 /* SemicolonToken */, + ",": 23 /* CommaToken */, + "<": 24 /* LessThanToken */, + ">": 25 /* GreaterThanToken */, + "<=": 26 /* LessThanEqualsToken */, + ">=": 27 /* GreaterThanEqualsToken */, + "==": 28 /* EqualsEqualsToken */, + "!=": 29 /* ExclamationEqualsToken */, + "===": 30 /* EqualsEqualsEqualsToken */, + "!==": 31 /* ExclamationEqualsEqualsToken */, + "=>": 32 /* EqualsGreaterThanToken */, + "+": 33 /* PlusToken */, + "-": 34 /* MinusToken */, + "*": 35 /* AsteriskToken */, + "/": 36 /* SlashToken */, + "%": 37 /* PercentToken */, + "++": 38 /* PlusPlusToken */, + "--": 39 /* MinusMinusToken */, + "<<": 40 /* LessThanLessThanToken */, + ">>": 41 /* GreaterThanGreaterThanToken */, + ">>>": 42 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 43 /* AmpersandToken */, + "|": 44 /* BarToken */, + "^": 45 /* CaretToken */, + "!": 46 /* ExclamationToken */, + "~": 47 /* TildeToken */, + "&&": 48 /* AmpersandAmpersandToken */, + "||": 49 /* BarBarToken */, + "?": 50 /* QuestionToken */, + ":": 51 /* ColonToken */, + "=": 52 /* EqualsToken */, + "+=": 53 /* PlusEqualsToken */, + "-=": 54 /* MinusEqualsToken */, + "*=": 55 /* AsteriskEqualsToken */, + "/=": 56 /* SlashEqualsToken */, + "%=": 57 /* PercentEqualsToken */, + "<<=": 58 /* LessThanLessThanEqualsToken */, + ">>=": 59 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 61 /* AmpersandEqualsToken */, + "|=": 62 /* BarEqualsToken */, + "^=": 63 /* CaretEqualsToken */ }; 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,]; @@ -1430,12 +1465,14 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; + } case 10 /* lineFeed */: pos++; - if (stopAfterLineBreak) + if (stopAfterLineBreak) { return pos; + } continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -1466,6 +1503,14 @@ var ts; continue; } break; + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -1477,6 +1522,28 @@ var ts; } } ts.skipTrivia = skipTrivia; + function isConflictMarkerTrivia(text, pos) { + if (pos > 0 && isLineBreak(text.charCodeAt(pos - 1))) { + var ch = text.charCodeAt(pos); + var markerLength = "<<<<<<<".length; + if ((pos + markerLength) < text.length) { + for (var i = 0, n = markerLength; i < n; i++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } + } + return ch === 61 /* equals */ || text.charCodeAt(pos + markerLength) === 32 /* space */; + } + } + return false; + } + function scanConflictMarkerTrivia(text, pos) { + var len = text.length; + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -1563,7 +1630,7 @@ var ts; return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - function createScanner(languageVersion, skipTrivia, text, onError, onComment) { + function createScanner(languageVersion, skipTrivia, text, onError) { var pos; var len; var startPos; @@ -1571,6 +1638,7 @@ var ts; var token; var tokenValue; var precedingLineBreak; + var tokenIsUnterminated; function error(message) { if (onError) { onError(message); @@ -1647,6 +1715,7 @@ var ts; while (true) { if (pos >= len) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1664,6 +1733,7 @@ var ts; } if (isLineBreak(ch)) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1680,21 +1750,22 @@ var ts; while (true) { if (pos >= len) { contents += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; break; } if (currChar === 36 /* $ */ && pos + 1 < len && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 10 /* TemplateHead */ : 11 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; break; } if (currChar === 92 /* backslash */) { @@ -1705,10 +1776,10 @@ var ts; } if (currChar === 13 /* carriageReturn */) { contents += text.substring(start, pos); - if (pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } - pos++; contents += "\n"; start = pos; continue; @@ -1810,11 +1881,31 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 63 /* Identifier */; + return token = 64 /* Identifier */; + } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; } function scan() { startPos = pos; precedingLineBreak = false; + tokenIsUnterminated = false; while (true) { tokenPos = pos; if (pos >= len) { @@ -1855,66 +1946,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 30 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 31 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 28 /* ExclamationEqualsToken */; + return pos += 2, token = 29 /* ExclamationEqualsToken */; } - return pos++, token = 45 /* ExclamationToken */; + return pos++, token = 46 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 7 /* StringLiteral */; + return token = 8 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PercentEqualsToken */; + return pos += 2, token = 57 /* PercentEqualsToken */; } - return pos++, token = 36 /* PercentToken */; + return pos++, token = 37 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 47 /* AmpersandAmpersandToken */; + return pos += 2, token = 48 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* AmpersandEqualsToken */; + return pos += 2, token = 61 /* AmpersandEqualsToken */; } - return pos++, token = 42 /* AmpersandToken */; + return pos++, token = 43 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 15 /* OpenParenToken */; + return pos++, token = 16 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 16 /* CloseParenToken */; + return pos++, token = 17 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* AsteriskEqualsToken */; + return pos += 2, token = 55 /* AsteriskEqualsToken */; } - return pos++, token = 34 /* AsteriskToken */; + return pos++, token = 35 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 37 /* PlusPlusToken */; + return pos += 2, token = 38 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 52 /* PlusEqualsToken */; + return pos += 2, token = 53 /* PlusEqualsToken */; } - return pos++, token = 32 /* PlusToken */; + return pos++, token = 33 /* PlusToken */; case 44 /* comma */: - return pos++, token = 22 /* CommaToken */; + return pos++, token = 23 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 38 /* MinusMinusToken */; + return pos += 2, token = 39 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 53 /* MinusEqualsToken */; + return pos += 2, token = 54 /* MinusEqualsToken */; } - return pos++, token = 33 /* MinusToken */; + return pos++, token = 34 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 20 /* DotDotDotToken */; + return pos += 3, token = 21 /* DotDotDotToken */; } - return pos++, token = 19 /* DotToken */; + return pos++, token = 20 /* DotToken */; case 47 /* slash */: if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; @@ -1924,9 +2015,6 @@ var ts; } pos++; } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } @@ -1952,20 +2040,18 @@ var ts; if (!commentClosed) { error(ts.Diagnostics.Asterisk_Slash_expected); } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } else { + tokenIsUnterminated = !commentClosed; return token = 3 /* MultiLineCommentTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* SlashEqualsToken */; + return pos += 2, token = 56 /* SlashEqualsToken */; } - return pos++, token = 35 /* SlashToken */; + return pos++, token = 36 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < len && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -1975,11 +2061,31 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 7 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 7 /* NumericLiteral */; } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; } case 49 /* _1 */: case 50 /* _2 */: @@ -1991,60 +2097,90 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 50 /* ColonToken */; + return pos++, token = 51 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 21 /* SemicolonToken */; + return pos++, token = 22 /* SemicolonToken */; case 60 /* lessThan */: + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 57 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 58 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 39 /* LessThanLessThanToken */; + return pos += 2, token = 40 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 25 /* LessThanEqualsToken */; + return pos += 2, token = 26 /* LessThanEqualsToken */; } - return pos++, token = 23 /* LessThanToken */; + return pos++, token = 24 /* LessThanToken */; case 61 /* equals */: + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 29 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 30 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 27 /* EqualsEqualsToken */; + return pos += 2, token = 28 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 31 /* EqualsGreaterThanToken */; + return pos += 2, token = 32 /* EqualsGreaterThanToken */; } - return pos++, token = 51 /* EqualsToken */; + return pos++, token = 52 /* EqualsToken */; case 62 /* greaterThan */: - return pos++, token = 24 /* GreaterThanToken */; + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } + return pos++, token = 25 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 49 /* QuestionToken */; + return pos++, token = 50 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 17 /* OpenBracketToken */; + return pos++, token = 18 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 18 /* CloseBracketToken */; + return pos++, token = 19 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* CaretEqualsToken */; + return pos += 2, token = 63 /* CaretEqualsToken */; } - return pos++, token = 44 /* CaretToken */; + return pos++, token = 45 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 13 /* OpenBraceToken */; + return pos++, token = 14 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 48 /* BarBarToken */; + return pos += 2, token = 49 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* BarEqualsToken */; + return pos += 2, token = 62 /* BarEqualsToken */; } - return pos++, token = 43 /* BarToken */; + return pos++, token = 44 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 14 /* CloseBraceToken */; + return pos++, token = 15 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 46 /* TildeToken */; + return pos++, token = 47 /* TildeToken */; case 92 /* backslash */: var ch = peekUnicodeEscape(); if (ch >= 0 && isIdentifierStart(ch)) { @@ -2080,37 +2216,39 @@ var ts; } } function reScanGreaterToken() { - if (token === 24 /* GreaterThanToken */) { + if (token === 25 /* 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 = 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 41 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 42 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 59 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 40 /* GreaterThanGreaterThanToken */; + return pos++, token = 41 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 26 /* GreaterThanEqualsToken */; + return pos++, token = 27 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) { + if (token === 36 /* SlashToken */ || token === 56 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; while (true) { if (p >= len) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -2137,16 +2275,16 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 8 /* RegularExpressionLiteral */; + token = 9 /* RegularExpressionLiteral */; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 14 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } - function tryScan(callback) { + function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; var saveTokenPos = tokenPos; @@ -2154,7 +2292,7 @@ var ts; var saveTokenValue = tokenValue; var savePrecedingLineBreak = precedingLineBreak; var result = callback(); - if (!result) { + if (!result || isLookahead) { pos = savePos; startPos = saveStartPos; tokenPos = saveTokenPos; @@ -2164,6 +2302,12 @@ var ts; } return result; } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } function setText(newText) { text = newText || ""; len = text.length; @@ -2185,36 +2329,89 @@ var ts; getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, + isIdentifier: function () { return token === 64 /* Identifier */ || token > 100 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 65 /* FirstReservedWord */ && token <= 100 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, - tryScan: tryScan + tryScan: tryScan, + lookAhead: lookAhead }; } ts.createScanner = createScanner; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(200 /* Count */); - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + for (var i = 0; i < declarations.length; i++) { + var declaration = declarations[i]; + if (declaration.kind === kind) { + return declaration; + } + } + return undefined; } - ts.getNodeConstructor = getNodeConstructor; - function createRootNode(kind, pos, end, flags) { - var node = new (getNodeConstructor(kind))(); - node.pos = pos; - node.end = end; - node.flags = flags; - return node; + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + ts.hasFlag = hasFlag; + function containsParseError(node) { + if (!hasFlag(node.parserContextFlags, 64 /* HasComputedThisNodeOrAnySubNodesHasError */)) { + var val = hasFlag(node.parserContextFlags, 16 /* ThisNodeHasError */) || ts.forEachChild(node, containsParseError); + if (val) { + node.parserContextFlags |= 32 /* ThisNodeOrAnySubNodesHasError */; + } + node.parserContextFlags |= 64 /* HasComputedThisNodeOrAnySubNodesHasError */; + } + return hasFlag(node.parserContextFlags, 32 /* ThisNodeOrAnySubNodesHasError */); + } + ts.containsParseError = containsParseError; function getSourceFileOfNode(node) { - while (node && node.kind !== 197 /* SourceFile */) + while (node && node.kind !== 207 /* SourceFile */) { node = node.parent; + } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; @@ -2228,19 +2425,29 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; + function isMissingNode(node) { + return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + } + ts.isMissingNode = isMissingNode; function getTokenPosOfNode(node, sourceFile) { - if (node.pos === node.end) { + if (isMissingNode(node)) { return node.pos; } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + if (isMissingNode(node)) { + return ""; + } var text = sourceFile.text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { + if (isMissingNode(node)) { + return ""; + } return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; @@ -2257,13 +2464,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function declarationNameToString(name) { - return name.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(name); + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = getTokenPosOfNode(node, file); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2279,12 +2486,13 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 195 /* ModuleDeclaration */: + case 194 /* EnumDeclaration */: + case 206 /* EnumMember */: errorSpan = node.name; break; } @@ -2300,7 +2508,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 191 /* EnumDeclaration */ && isConst(node); + return node.kind === 194 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -2312,19 +2520,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 172 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); - } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(isPrologueDirective(node)); - return node.expression.text === "use strict"; - } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { + if (node.kind === 124 /* Parameter */ || node.kind === 123 /* TypeParameter */) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -2333,184 +2534,35 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) - return cbNode(node); - } - function children(nodes) { - if (nodes) { - if (cbNodes) - return cbNodes(nodes); - var result; - for (var i = 0, len = nodes.length; i < len; i++) { - if (result = cbNode(nodes[i])) - break; - } - return result; - } - } - if (!node) - return; - switch (node.kind) { - case 121 /* QualifiedName */: - return child(node.left) || child(node.right); - case 122 /* TypeParameter */: - return child(node.name) || child(node.constraint); - case 123 /* Parameter */: - return child(node.name) || child(node.type) || child(node.initializer); - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - return child(node.name) || child(node.type) || child(node.initializer); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 132 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); - case 135 /* TypeQuery */: - return child(node.exprName); - case 136 /* TypeLiteral */: - return children(node.members); - case 137 /* ArrayType */: - return child(node.elementType); - case 138 /* TupleType */: - return children(node.elementTypes); - case 139 /* UnionType */: - return children(node.types); - case 140 /* ParenType */: - return child(node.type); - case 141 /* ArrayLiteral */: - return children(node.elements); - case 142 /* ObjectLiteral */: - return children(node.properties); - case 145 /* PropertyAccess */: - return child(node.left) || child(node.right); - case 146 /* IndexedAccess */: - return child(node.object) || child(node.index); - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 149 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); - case 150 /* TypeAssertion */: - return child(node.type) || child(node.operand); - case 151 /* ParenExpression */: - return child(node.expression); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return child(node.operand); - case 156 /* BinaryExpression */: - return child(node.left) || child(node.right); - case 157 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: - return children(node.statements); - case 163 /* VariableStatement */: - return children(node.declarations); - case 165 /* ExpressionStatement */: - return child(node.expression); - case 166 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 167 /* DoStatement */: - return child(node.statement) || child(node.expression); - case 168 /* WhileStatement */: - return child(node.expression) || child(node.statement); - case 169 /* ForStatement */: - return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 170 /* ForInStatement */: - return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - return child(node.label); - case 173 /* ReturnStatement */: - return child(node.expression); - case 174 /* WithStatement */: - return child(node.expression) || child(node.statement); - case 175 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return child(node.expression) || children(node.statements); - case 178 /* LabeledStatement */: - return child(node.label) || child(node.statement); - case 179 /* ThrowStatement */: - return child(node.expression); - case 180 /* TryStatement */: - return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 182 /* CatchBlock */: - return child(node.variable) || children(node.statements); - case 185 /* VariableDeclaration */: - return child(node.name) || child(node.type) || child(node.initializer); - case 188 /* ClassDeclaration */: - return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 189 /* InterfaceDeclaration */: - return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 190 /* TypeAliasDeclaration */: - return child(node.name) || child(node.type); - case 191 /* EnumDeclaration */: - return child(node.name) || children(node.members); - case 196 /* EnumMember */: - return child(node.name) || child(node.initializer); - case 192 /* ModuleDeclaration */: - return child(node.name) || child(node.body); - case 194 /* ImportDeclaration */: - return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 195 /* ExportAssignment */: - return child(node.exportName); - case 158 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); - case 159 /* TemplateSpan */: - return child(node.expression) || child(node.literal); - } - } - ts.forEachChild = forEachChild; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return visitor(node); - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - return forEachChild(node, traverse); + case 169 /* Block */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + return ts.forEachChild(node, traverse); } } } @@ -2518,19 +2570,36 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: + case 129 /* Constructor */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: return true; } } return false; } ts.isAnyFunction = isAnyFunction; + function isFunctionBlock(node) { + return node && node.kind === 169 /* Block */ && isAnyFunction(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 128 /* MethodDeclaration */ && node.parent.kind === 148 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { while (true) { node = node.parent; @@ -2547,20 +2616,22 @@ var ts; return undefined; } switch (node.kind) { - case 153 /* ArrowFunction */: + case 157 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 192 /* ModuleDeclaration */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 191 /* EnumDeclaration */: - case 197 /* SourceFile */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 195 /* ModuleDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 194 /* EnumDeclaration */: + case 207 /* SourceFile */: return node; } } @@ -2573,86 +2644,94 @@ var ts; return undefined; } switch (node.kind) { - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { return node.tag; } - return node.func; + return node.expression; } ts.getInvokedExpression = getInvokedExpression; function isExpression(node) { switch (node.kind) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 8 /* RegularExpressionLiteral */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 158 /* TemplateExpression */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 161 /* OmittedExpression */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: + case 9 /* RegularExpressionLiteral */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 153 /* TaggedTemplateExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 160 /* VoidExpression */: + case 158 /* DeleteExpression */: + case 159 /* TypeOfExpression */: + case 161 /* PrefixUnaryExpression */: + case 162 /* PostfixUnaryExpression */: + case 163 /* BinaryExpression */: + case 164 /* ConditionalExpression */: + case 165 /* TemplateExpression */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 167 /* OmittedExpression */: return true; case 121 /* QualifiedName */: - while (node.parent.kind === 121 /* QualifiedName */) + while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; - return node.parent.kind === 135 /* TypeQuery */; - case 63 /* Identifier */: - if (node.parent.kind === 135 /* TypeQuery */) { + } + return node.parent.kind === 138 /* TypeQuery */; + case 64 /* Identifier */: + if (node.parent.kind === 138 /* TypeQuery */) { return true; } - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: - case 196 /* EnumMember */: - case 143 /* PropertyAssignment */: + case 189 /* VariableDeclaration */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 206 /* EnumMember */: + case 204 /* PropertyAssignment */: + case 146 /* BindingElement */: return parent.initializer === node; - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 179 /* ThrowStatement */: - case 175 /* SwitchStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 184 /* ThrowStatement */: + case 182 /* SwitchStatement */: return parent.expression === node; - case 169 /* ForStatement */: + case 176 /* ForStatement */: return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return parent.variable === node || parent.expression === node; - case 150 /* TypeAssertion */: - return node === parent.operand; - case 159 /* TemplateSpan */: + case 154 /* TypeAssertionExpression */: + return node === parent.expression; + case 168 /* TemplateSpan */: return node === parent.expression; default: if (isExpression(parent)) { @@ -2663,22 +2742,61 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleImportDeclaration(node) { + return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */; + } + ts.isExternalModuleImportDeclaration = isExternalModuleImportDeclaration; + function getExternalModuleImportDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportDeclarationExpression = getExternalModuleImportDeclarationExpression; + function isInternalModuleImportDeclaration(node) { + return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind !== 199 /* ExternalModuleReference */; + } + ts.isInternalModuleImportDeclaration = isInternalModuleImportDeclaration; + function hasDotDotDotToken(node) { + return node && node.kind === 124 /* Parameter */ && node.dotDotDotToken !== undefined; + } + ts.hasDotDotDotToken = hasDotDotDotToken; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 124 /* Parameter */: + return node.questionToken !== undefined; + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return node.questionToken !== undefined; + case 205 /* ShorthandPropertyAssignment */: + case 204 /* PropertyAssignment */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; + return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { - return 6 /* FirstLiteralToken */ <= kind && kind <= 9 /* LastLiteralToken */; + return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 7 /* StringLiteral */ || kind === 9 /* NoSubstitutionTemplateLiteral */; + return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 9 /* FirstTemplateToken */ <= kind && kind <= 12 /* LastTemplateToken */; + return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return node.kind === 145 /* ArrayBindingPattern */ || node.kind === 144 /* ObjectBindingPattern */; + } + ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { if (node.flags & (2 /* Ambient */ | 1024 /* DeclarationFile */)) @@ -2690,24 +2808,27 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 122 /* TypeParameter */: - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 123 /* TypeParameter */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 190 /* FunctionDeclaration */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return true; } return false; @@ -2715,24 +2836,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 184 /* DebuggerStatement */: - case 167 /* DoStatement */: - case 165 /* ExpressionStatement */: - case 164 /* EmptyStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - case 178 /* LabeledStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 92 /* ThrowKeyword */: - case 180 /* TryStatement */: - case 163 /* VariableStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 195 /* ExportAssignment */: + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 188 /* DebuggerStatement */: + case 174 /* DoStatement */: + case 172 /* ExpressionStatement */: + case 171 /* EmptyStatement */: + case 177 /* ForInStatement */: + case 176 /* ForStatement */: + case 173 /* IfStatement */: + case 183 /* LabeledStatement */: + case 180 /* ReturnStatement */: + case 182 /* SwitchStatement */: + case 93 /* ThrowKeyword */: + case 185 /* TryStatement */: + case 170 /* VariableStatement */: + case 175 /* WhileStatement */: + case 181 /* WithStatement */: + case 198 /* ExportAssignment */: return true; default: return false; @@ -2740,19 +2861,45 @@ var ts; } ts.isStatement = isStatement; function isDeclarationOrFunctionExpressionOrCatchVariableName(name) { - if (name.kind !== 63 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { + if (name.kind !== 64 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 156 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 182 /* CatchBlock */) { - return parent.variable === name; + if (parent.kind === 203 /* CatchClause */) { + return parent.name === name; } return false; } ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; + function getClassBaseTypeNode(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 78 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassBaseTypeNode = getClassBaseTypeNode; + function getClassImplementedTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 101 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 78 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var i = 0, n = clauses.length; i < n; i++) { + if (clauses[i].token === kind) { + return clauses[i]; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; function tryResolveScriptReference(program, sourceFile, reference) { if (!program.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename); @@ -2763,16 +2910,16 @@ var ts; ts.tryResolveScriptReference = tryResolveScriptReference; function getAncestor(node, kind) { switch (kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return node; - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 194 /* EnumDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -2792,28 +2939,6 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - function parsingContextErrors(context) { - switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - } - } - ; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; @@ -2839,7 +2964,7 @@ var ts; } else { return { - diagnostic: ts.Diagnostics.Invalid_reference_directive_syntax, + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, isNoDefaultLib: false }; } @@ -2849,62 +2974,366 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 64 /* FirstKeyword */ <= token && token <= 119 /* LastKeyword */; + return 65 /* FirstKeyword */ <= token && token <= 120 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isUnterminatedTemplateEnd(node) { - ts.Debug.assert(isTemplateLiteralKind(node.kind)); - var sourceText = getSourceFileOfNode(node).text; - if (node.end !== sourceText.length) { - return false; - } - if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) { - return false; - } - return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0; - } - ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd; function isModifier(token) { switch (token) { - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - case 76 /* ExportKeyword */: - case 112 /* DeclareKeyword */: + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + case 77 /* ExportKeyword */: + case 113 /* DeclareKeyword */: + case 69 /* ConstKeyword */: return true; } return false; } ts.isModifier = isModifier; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(210 /* Count */); + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind) { + return new (getNodeConstructor(kind))(); + } + ts.createNode = createNode; + function forEachChild(node, cbNode, cbNodes) { + function child(node) { + if (node) { + return cbNode(node); + } + } + function children(nodes) { + if (nodes) { + if (cbNodes) { + return cbNodes(nodes); + } + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; + } + } + return undefined; + } + } + if (!node) { + return; + } + switch (node.kind) { + case 121 /* QualifiedName */: + return child(node.left) || child(node.right); + case 123 /* TypeParameter */: + return child(node.name) || child(node.constraint); + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + return children(node.modifiers) || child(node.propertyName) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + return children(node.modifiers) || child(node.asteriskToken) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + case 135 /* TypeReference */: + return child(node.typeName) || children(node.typeArguments); + case 138 /* TypeQuery */: + return child(node.exprName); + case 139 /* TypeLiteral */: + return children(node.members); + case 140 /* ArrayType */: + return child(node.elementType); + case 141 /* TupleType */: + return children(node.elementTypes); + case 142 /* UnionType */: + return children(node.types); + case 143 /* ParenthesizedType */: + return child(node.type); + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + return children(node.elements); + case 147 /* ArrayLiteralExpression */: + return children(node.elements); + case 148 /* ObjectLiteralExpression */: + return children(node.properties); + case 149 /* PropertyAccessExpression */: + return child(node.expression) || child(node.name); + case 150 /* ElementAccessExpression */: + return child(node.expression) || child(node.argumentExpression); + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return child(node.expression) || children(node.typeArguments) || children(node.arguments); + case 153 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 154 /* TypeAssertionExpression */: + return child(node.type) || child(node.expression); + case 155 /* ParenthesizedExpression */: + return child(node.expression); + case 158 /* DeleteExpression */: + return child(node.expression); + case 159 /* TypeOfExpression */: + return child(node.expression); + case 160 /* VoidExpression */: + return child(node.expression); + case 161 /* PrefixUnaryExpression */: + return child(node.operand); + case 166 /* YieldExpression */: + return child(node.asteriskToken) || child(node.expression); + case 162 /* PostfixUnaryExpression */: + return child(node.operand); + case 163 /* BinaryExpression */: + return child(node.left) || child(node.right); + case 164 /* ConditionalExpression */: + return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: + return children(node.statements); + case 207 /* SourceFile */: + return children(node.statements) || child(node.endOfFileToken); + case 170 /* VariableStatement */: + return children(node.modifiers) || children(node.declarations); + case 172 /* ExpressionStatement */: + return child(node.expression); + case 173 /* IfStatement */: + return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + case 174 /* DoStatement */: + return child(node.statement) || child(node.expression); + case 175 /* WhileStatement */: + return child(node.expression) || child(node.statement); + case 176 /* ForStatement */: + return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + case 177 /* ForInStatement */: + return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + return child(node.label); + case 180 /* ReturnStatement */: + return child(node.expression); + case 181 /* WithStatement */: + return child(node.expression) || child(node.statement); + case 182 /* SwitchStatement */: + return child(node.expression) || children(node.clauses); + case 200 /* CaseClause */: + return child(node.expression) || children(node.statements); + case 201 /* DefaultClause */: + return children(node.statements); + case 183 /* LabeledStatement */: + return child(node.label) || child(node.statement); + case 184 /* ThrowStatement */: + return child(node.expression); + case 185 /* TryStatement */: + return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + case 203 /* CatchClause */: + return child(node.name) || child(node.type) || child(node.block); + case 191 /* ClassDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 192 /* InterfaceDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 193 /* TypeAliasDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type); + case 194 /* EnumDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.members); + case 206 /* EnumMember */: + return child(node.name) || child(node.initializer); + case 195 /* ModuleDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.body); + case 197 /* ImportDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.moduleReference); + case 198 /* ExportAssignment */: + return children(node.modifiers) || child(node.exportName); + case 165 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 168 /* TemplateSpan */: + return child(node.expression) || child(node.literal); + case 122 /* ComputedPropertyName */: + return child(node.expression); + case 202 /* HeritageClause */: + return children(node.types); + case 199 /* ExternalModuleReference */: + return child(node.expression); + } + } + ts.forEachChild = forEachChild; + function createCompilerHost(options) { + var currentDirectory; + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(filename, languageVersion, onError) { + try { + var text = ts.sys.readFile(filename, options.charset); + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText : e.message); + } + text = ""; + } + return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined; + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + try { + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + return { + getSourceFile: getSourceFile, + getDefaultLibFilename: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"); }, + writeFile: writeFile, + getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return ts.sys.newLine; } + }; + } + ts.createCompilerHost = createCompilerHost; + function parsingContextErrors(context) { + switch (context) { + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* TypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + } + } + ; function modifierToFlag(token) { switch (token) { - case 107 /* StaticKeyword */: return 128 /* Static */; - case 106 /* PublicKeyword */: return 16 /* Public */; - case 105 /* ProtectedKeyword */: return 64 /* Protected */; - case 104 /* PrivateKeyword */: return 32 /* Private */; - case 76 /* ExportKeyword */: return 1 /* Export */; - case 112 /* DeclareKeyword */: return 2 /* Ambient */; + case 108 /* StaticKeyword */: return 128 /* Static */; + case 107 /* PublicKeyword */: return 16 /* Public */; + case 106 /* ProtectedKeyword */: return 64 /* Protected */; + case 105 /* PrivateKeyword */: return 32 /* Private */; + case 77 /* ExportKeyword */: return 1 /* Export */; + case 113 /* DeclareKeyword */: return 2 /* Ambient */; + case 69 /* ConstKeyword */: return 4096 /* Const */; } return 0; } - function createSourceFile(filename, sourceText, languageVersion, version, isOpen) { - if (isOpen === void 0) { isOpen = false; } - var file; - var scanner; - var token; + function fixupParentReferences(sourceFile) { + var parent = sourceFile; + function walk(n) { + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, walk); + parent = saveParent; + } + } + forEachChild(sourceFile, walk); + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 64 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); + } + function isUseStrictPrologueDirective(sourceFile, node) { + ts.Debug.assert(ts.isPrologueDirective(node)); + var nodeText = ts.getSourceTextOfNodeFromSourceFile(sourceFile, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; + } + function createSourceFile(filename, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } var parsingContext; - var commentRanges; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var lineStarts; - var lookAheadMode = 0 /* NotLookingAhead */; var contextFlags = 0; + var parseErrorBeforeNextFinishedNode = false; + var sourceFile = createNode(207 /* SourceFile */, 0); + if (ts.fileExtensionIs(filename, ".d.ts")) { + sourceFile.flags = 1024 /* DeclarationFile */; + } + sourceFile.end = sourceText.length; + sourceFile.filename = ts.normalizePath(filename); + sourceFile.text = sourceText; + sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; + sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; + sourceFile.getLineStarts = getLineStarts; + sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; + sourceFile.referenceDiagnostics = []; + sourceFile.parseDiagnostics = []; + sourceFile.grammarDiagnostics = []; + sourceFile.semanticDiagnostics = []; + processReferenceComments(); + var scanner = ts.createScanner(languageVersion, true, sourceText, scanError); + var token = nextToken(); + sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + sourceFile.externalModuleIndicator = getExternalModuleIndicator(); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.languageVersion = languageVersion; + sourceFile.identifiers = identifiers; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + return sourceFile; function setContextFlag(val, flag) { if (val) { contextFlags |= flag; @@ -2982,29 +3411,21 @@ var ts; function getPositionFromSourceLineAndCharacter(line, character) { return ts.getPositionFromLineAndCharacter(getLineStarts(), line, character); } - function error(message, arg0, arg1, arg2) { + function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; - errorAtPos(start, length, message, arg0, arg1, arg2); + parseErrorAtPosition(start, length, message, arg0); } - function errorAtPos(start, length, message, arg0, arg1, arg2) { - var lastErrorPos = file.parseDiagnostics.length ? file.parseDiagnostics[file.parseDiagnostics.length - 1].start : -1; - if (start !== lastErrorPos) { - var diagnostic = ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); - diagnostic.isParseError = true; - file.parseDiagnostics.push(diagnostic); - } - if (lookAheadMode === 1 /* NoErrorYet */) { - lookAheadMode = 2 /* Error */; + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); + if (!lastError || start !== lastError.start) { + sourceFile.parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); } + parseErrorBeforeNextFinishedNode = true; } function scanError(message) { var pos = scanner.getTextPos(); - errorAtPos(pos, 0, message); - } - function onComment(pos, end) { - if (commentRanges) - commentRanges.push({ pos: pos, end: end }); + parseErrorAtPosition(pos, 0, message); } function getNodePos() { return scanner.getStartPos(); @@ -3027,49 +3448,46 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } - function lookAheadHelper(callback, alwaysResetState) { + function speculationHelper(callback, isLookAhead) { var saveToken = token; - var saveSyntacticErrorsLength = file.parseDiagnostics.length; - var saveLookAheadMode = lookAheadMode; - lookAheadMode = 1 /* NoErrorYet */; - var result = callback(); - ts.Debug.assert(lookAheadMode === 2 /* Error */ || lookAheadMode === 1 /* NoErrorYet */); - if (lookAheadMode === 2 /* Error */) { - result = undefined; - } - lookAheadMode = saveLookAheadMode; - if (!result || alwaysResetState) { + var saveParseDiagnosticsLength = sourceFile.parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { token = saveToken; - file.parseDiagnostics.length = saveSyntacticErrorsLength; + sourceFile.parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; } return result; } function lookAhead(callback) { - var result; - scanner.tryScan(function () { - result = lookAheadHelper(callback, true); - return false; - }); - return result; + return speculationHelper(callback, true); } function tryParse(callback) { - return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); + return speculationHelper(callback, false); } function isIdentifier() { - if (token === 63 /* Identifier */) { + if (token === 64 /* Identifier */) { return true; } - if (token === 108 /* YieldKeyword */ && inYieldContext()) { + if (token === 109 /* YieldKeyword */ && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */; + return inStrictModeContext() ? token > 109 /* LastFutureReservedWord */ : token > 100 /* LastReservedWord */; } - function parseExpected(t) { - if (token === t) { + function parseExpected(kind, diagnosticMessage, arg0) { + if (token === kind) { nextToken(); return true; } - error(ts.Diagnostics._0_expected, ts.tokenToString(t)); + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } return false; } function parseOptional(t) { @@ -3088,19 +3506,20 @@ var ts; return undefined; } function canParseSemicolon() { - if (token === 21 /* SemicolonToken */) { + if (token === 22 /* SemicolonToken */) { return true; } - return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } - function parseSemicolon() { + function parseSemicolon(diagnosticMessage) { if (canParseSemicolon()) { - if (token === 21 /* SemicolonToken */) { + if (token === 22 /* SemicolonToken */) { nextToken(); } + return true; } else { - error(ts.Diagnostics._0_expected, ";"); + return parseExpected(22 /* SemicolonToken */, diagnosticMessage); } } function createNode(kind, pos) { @@ -3118,54 +3537,88 @@ var ts; if (contextFlags) { node.parserContextFlags = contextFlags; } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ThisNodeHasError */; + } return node; } - function createMissingNode(pos) { - return createNode(120 /* Missing */, pos); + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); } function internIdentifier(text) { - text = escapeIdentifier(text); + text = ts.escapeIdentifier(text); return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); } - function createIdentifier(isIdentifier) { + function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(63 /* Identifier */); + var node = createNode(64 /* Identifier */); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - error(ts.Diagnostics.Identifier_expected); - var node = createMissingNode(); - node.text = ""; - return node; + return createMissingNode(64 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } - function parseIdentifier() { - return createIdentifier(isIdentifier()); + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(token >= 63 /* Identifier */); + return createIdentifier(isIdentifierOrKeyword()); } - function isPropertyName() { - return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + function isLiteralPropertyName() { + return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */; } function parsePropertyName() { - if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { + if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { return parseLiteralNode(true); } + if (token === 18 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } return parseIdentifierName(); } + function parseComputedPropertyName() { + var node = createNode(122 /* ComputedPropertyName */); + parseExpected(18 /* OpenBracketToken */); + var yieldContext = inYieldContext(); + if (inGeneratorParameterContext()) { + setYieldContext(false); + } + node.expression = allowInAnd(parseExpression); + if (inGeneratorParameterContext()) { + setYieldContext(yieldContext); + } + parseExpected(19 /* CloseBracketToken */); + return finishNode(node); + } function parseContextualModifier(t) { - return token === t && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || isPropertyName(); - }); + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + nextToken(); + return canFollowModifier(); } function parseAnyContextualModifier() { - return isModifier(token) && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName(); - }); + return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); + } + function nextTokenCanFollowContextualModifier() { + if (token === 69 /* ConstKeyword */) { + return nextToken() === 76 /* EnumKeyword */; + } + nextToken(); + return canFollowModifier(); + } + function canFollowModifier() { + return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); } function isListElement(kind, inErrorRecovery) { switch (kind) { @@ -3176,32 +3629,49 @@ var ts; case 4 /* SwitchClauseStatements */: return isStatement(inErrorRecovery); case 3 /* SwitchClauses */: - return token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; + return token === 66 /* CaseKeyword */ || token === 72 /* DefaultKeyword */; case 5 /* TypeMembers */: return isStartOfTypeMember(); case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: - return isPropertyName(); - case 11 /* ObjectLiteralMembers */: - return token === 34 /* AsteriskToken */ || isPropertyName(); - case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + case 13 /* ObjectLiteralMembers */: + return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); + case 10 /* ObjectBindingElements */: + return isLiteralPropertyName(); + case 8 /* TypeReferences */: + return isIdentifier() && !isNotHeritageClauseTypeName(); case 9 /* VariableDeclarations */: - case 14 /* TypeParameters */: + return isIdentifierOrPattern(); + case 11 /* ArrayBindingElements */: + return token === 23 /* CommaToken */ || isIdentifierOrPattern(); + case 16 /* TypeParameters */: return isIdentifier(); - case 10 /* ArgumentExpressions */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 12 /* ArrayLiteralMembers */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 13 /* Parameters */: + case 12 /* ArgumentExpressions */: + return token === 23 /* CommaToken */ || isStartOfExpression(); + case 14 /* ArrayLiteralMembers */: + return token === 23 /* CommaToken */ || isStartOfExpression(); + case 15 /* Parameters */: return isStartOfParameter(); - case 15 /* TypeArguments */: - case 16 /* TupleElementTypes */: - return token === 22 /* CommaToken */ || isStartOfType(); + case 17 /* TypeArguments */: + case 18 /* TupleElementTypes */: + return token === 23 /* CommaToken */ || isStartOfType(); + case 19 /* HeritageClauses */: + return isHeritageClause(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function isNotHeritageClauseTypeName() { + if (token === 101 /* ImplementsKeyword */ || token === 78 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsIdentifier); + } + return false; + } function isListTerminator(kind) { if (token === 1 /* EndOfFileToken */) { return true; @@ -3213,41 +3683,45 @@ var ts; case 5 /* TypeMembers */: case 6 /* ClassMembers */: case 7 /* EnumMembers */: - case 11 /* ObjectLiteralMembers */: - return token === 14 /* CloseBraceToken */; + case 13 /* ObjectLiteralMembers */: + case 10 /* ObjectBindingElements */: + return token === 15 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: - return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 8 /* BaseTypeReferences */: - return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; + return token === 15 /* CloseBraceToken */ || token === 66 /* CaseKeyword */ || token === 72 /* DefaultKeyword */; + case 8 /* TypeReferences */: + return token === 14 /* OpenBraceToken */ || token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 14 /* TypeParameters */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */ || token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; - case 10 /* ArgumentExpressions */: - return token === 16 /* CloseParenToken */ || token === 21 /* SemicolonToken */; - case 12 /* ArrayLiteralMembers */: - case 16 /* TupleElementTypes */: - return token === 18 /* CloseBracketToken */; - case 13 /* Parameters */: - return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; - case 15 /* TypeArguments */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; + case 16 /* TypeParameters */: + return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; + case 12 /* ArgumentExpressions */: + return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + case 14 /* ArrayLiteralMembers */: + case 18 /* TupleElementTypes */: + case 11 /* ArrayBindingElements */: + return token === 19 /* CloseBracketToken */; + case 15 /* Parameters */: + return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */; + case 17 /* TypeArguments */: + return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + case 19 /* HeritageClauses */: + return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { if (canParseSemicolon()) { return true; } - if (token === 84 /* InKeyword */) { + if (token === 85 /* InKeyword */) { return true; } - if (token === 31 /* EqualsGreaterThanToken */) { + if (token === 32 /* EqualsGreaterThanToken */) { return true; } return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 17 /* Count */; kind++) { + for (var kind = 0; kind < 20 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -3266,9 +3740,9 @@ var ts; if (isListElement(kind, false)) { var element = parseElement(); result.push(element); - if (!inStrictModeContext() && checkForStrictMode) { - if (isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { + if (checkForStrictMode && !inStrictModeContext()) { + if (ts.isPrologueDirective(element)) { + if (isUseStrictPrologueDirective(sourceFile, element)) { setStrictModeContext(true); checkForStrictMode = false; } @@ -3277,13 +3751,10 @@ var ts; checkForStrictMode = false; } } + continue; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } setStrictModeContext(savedStrictModeContext); @@ -3291,6 +3762,14 @@ var ts; parsingContext = saveParsingContext; return result; } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } function parseDelimitedList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -3301,24 +3780,21 @@ var ts; if (isListElement(kind, false)) { result.push(parseElement()); commaStart = scanner.getTokenPos(); - if (parseOptional(22 /* CommaToken */)) { + if (parseOptional(23 /* CommaToken */)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - error(ts.Diagnostics._0_expected, ","); + parseExpected(23 /* CommaToken */); + continue; } - else if (isListTerminator(kind)) { + if (isListTerminator(kind)) { break; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } if (commaStart >= 0) { @@ -3343,46 +3819,53 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords) { - var entity = parseIdentifier(); - while (parseOptional(19 /* DotToken */)) { + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); + while (parseOptional(20 /* DotToken */)) { var node = createNode(121 /* QualifiedName */, entity.pos); node.left = entity; - node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); + node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); } return entity; } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(64 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } function parseTokenNode() { var node = createNode(token); nextToken(); return finishNode(node); } function parseTemplateExpression() { - var template = createNode(158 /* TemplateExpression */); + var template = createNode(165 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 11 /* TemplateMiddle */); + } while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(159 /* TemplateSpan */); + var span = createNode(168 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 14 /* CloseBraceToken */) { + if (token === 15 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - error(ts.Diagnostics.Invalid_template_literal_expected); - literal = createMissingNode(); - literal.text = ""; + literal = createMissingNode(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -3391,58 +3874,57 @@ var ts; var node = createNode(token); var text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 6 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + if (node.kind === 7 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 8192 /* OctalLiteral */; } return node; } - function parseStringLiteral() { - if (token === 7 /* StringLiteral */) { - return parseLiteralNode(true); - } - error(ts.Diagnostics.String_literal_expected); - return createMissingNode(); - } function parseTypeReference() { - var node = createNode(132 /* TypeReference */); - node.typeName = parseEntityName(false); - if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { - node.typeArguments = parseTypeArguments(); + var node = createNode(135 /* TypeReference */); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { + node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(135 /* TypeQuery */); - parseExpected(95 /* TypeOfKeyword */); + var node = createNode(138 /* TypeQuery */); + parseExpected(96 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(122 /* TypeParameter */); + var node = createNode(123 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(77 /* ExtendsKeyword */)) { + if (parseOptional(78 /* ExtendsKeyword */)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } else { - node.expression = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); } } return finishNode(node); } function parseTypeParameters() { - if (token === 23 /* LessThanToken */) { - return parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 23 /* LessThanToken */, 24 /* GreaterThanToken */); + if (token === 24 /* LessThanToken */) { + return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { - return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + if (parseOptional(51 /* ColonToken */)) { + return token === 8 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); + } + return undefined; } function isStartOfParameter() { - return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token); } function setModifiers(node, modifiers) { if (modifiers) { @@ -3451,19 +3933,14 @@ var ts; } } function parseParameter() { - var node = createNode(123 /* Parameter */); - var modifiers = parseModifiers(); - setModifiers(node, modifiers); - if (parseOptional(20 /* DotDotDotToken */)) { - node.flags |= 8 /* Rest */; - } - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier(); - if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { + var node = createNode(124 /* Parameter */); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - if (parseOptional(49 /* QuestionToken */)) { - node.flags |= 4 /* QuestionMark */; - } + node.questionToken = parseOptionalToken(50 /* QuestionToken */); node.type = parseParameterType(); node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); return finishNode(node); @@ -3471,17 +3948,10 @@ var ts; function parseParameterInitializer() { return parseInitializer(true); } - function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) { - var signature = {}; - fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature); - return signature; - } - function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) { - if (kind === 130 /* ConstructSignature */) { - parseExpected(86 /* NewKeyword */); - } + function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 32 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -3490,98 +3960,146 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext) { - if (parseExpected(15 /* OpenParenToken */)) { + function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { + if (parseExpected(16 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(13 /* Parameters */, parseParameter); - parseExpected(16 /* CloseParenToken */); + var result = parseDelimitedList(15 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); + if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + return undefined; + } return result; } - return createMissingList(); + return requireCompleteParameterList ? undefined : createMissingList(); } - function parseSignatureMember(kind, returnToken) { + function parseTypeMemberSemicolon() { + if (parseSemicolon()) { + return; + } + parseOptional(23 /* CommaToken */); + } + function parseSignatureMember(kind) { var node = createNode(kind); - fillSignature(kind, returnToken, false, false, node); - parseSemicolon(); + if (kind === 133 /* ConstructSignature */) { + parseExpected(87 /* NewKeyword */); + } + fillSignature(51 /* ColonToken */, false, false, node); + parseTypeMemberSemicolon(); return finishNode(node); } - function parseIndexSignatureMember(fullStart, modifiers) { - var node = createNode(131 /* IndexSignature */, fullStart); + function isIndexSignature() { + if (token !== 18 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */) { + return true; + } + if (token !== 50 /* QuestionToken */) { + return false; + } + nextToken(); + return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + } + function parseIndexSignatureDeclaration(fullStart, modifiers) { + var node = createNode(134 /* IndexSignature */, fullStart); setModifiers(node, modifiers); - node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); + node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethod() { + function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var flags = 0; - if (parseOptional(49 /* QuestionToken */)) { - flags = 4 /* QuestionMark */; - } - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var method = createNode(127 /* MethodSignature */, fullStart); method.name = name; - method.flags = flags; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method); - parseSemicolon(); + method.questionToken = questionToken; + fillSignature(51 /* ColonToken */, false, false, method); + parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(124 /* Property */, fullStart); + var property = createNode(125 /* PropertySignature */, fullStart); property.name = name; - property.flags = flags; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(property); } } function isStartOfTypeMember() { switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 17 /* OpenBracketToken */: + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + case 18 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); } } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 50 /* QuestionToken */ || token === 51 /* ColonToken */ || canParseSemicolon(); + } function parseTypeMember() { switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); - case 17 /* OpenBracketToken */: - return parseIndexSignatureMember(scanner.getStartPos(), undefined); - case 86 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { - return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + return parseSignatureMember(132 /* CallSignature */); + case 18 /* OpenBracketToken */: + return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined) : parsePropertyOrMethodSignature(); + case 87 /* NewKeyword */: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(133 /* ConstructSignature */); } - case 7 /* StringLiteral */: - case 6 /* NumericLiteral */: - return parsePropertyOrMethod(); + case 8 /* StringLiteral */: + case 7 /* NumericLiteral */: + return parsePropertyOrMethodSignature(); default: - if (token >= 63 /* Identifier */) { - return parsePropertyOrMethod(); + if (isIdentifierOrKeyword()) { + return parsePropertyOrMethodSignature(); } } } + function isStartOfConstructSignature() { + nextToken(); + return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + } function parseTypeLiteral() { - var node = createNode(136 /* TypeLiteral */); - node.members = parseObjectType(); + var node = createNode(139 /* TypeLiteral */); + node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseObjectType() { + function parseObjectTypeMembers() { var members; - if (parseExpected(13 /* OpenBraceToken */)) { + if (parseExpected(14 /* OpenBraceToken */)) { members = parseList(5 /* TypeMembers */, false, parseTypeMember); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { members = createMissingList(); @@ -3589,118 +4107,123 @@ var ts; return members; } function parseTupleType() { - var node = createNode(138 /* TupleType */); - node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); + var node = createNode(141 /* TupleType */); + node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } - function parseParenType() { - var node = createNode(140 /* ParenType */); - parseExpected(15 /* OpenParenToken */); + function parseParenthesizedType() { + var node = createNode(143 /* ParenthesizedType */); + parseExpected(16 /* OpenParenToken */); node.type = parseType(); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); return finishNode(node); } - function parseFunctionType(typeKind) { - var node = createNode(typeKind); - fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node); + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 137 /* ConstructorType */) { + parseExpected(87 /* NewKeyword */); + } + fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 19 /* DotToken */ ? undefined : node; + return token === 20 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 95 /* TypeOfKeyword */: + case 98 /* VoidKeyword */: + return parseTokenNode(); + case 96 /* TypeOfKeyword */: return parseTypeQuery(); - case 13 /* OpenBraceToken */: + case 14 /* OpenBraceToken */: return parseTypeLiteral(); - case 17 /* OpenBracketToken */: + case 18 /* OpenBracketToken */: return parseTupleType(); - case 15 /* OpenParenToken */: - return parseParenType(); + case 16 /* OpenParenToken */: + return parseParenthesizedType(); default: - if (isIdentifier()) { - return parseTypeReference(); - } + return parseTypeReference(); } - error(ts.Diagnostics.Type_expected); - return createMissingNode(); } function isStartOfType() { switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 95 /* TypeOfKeyword */: - case 13 /* OpenBraceToken */: - case 17 /* OpenBracketToken */: - case 23 /* LessThanToken */: - case 86 /* NewKeyword */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: + case 98 /* VoidKeyword */: + case 96 /* TypeOfKeyword */: + case 14 /* OpenBraceToken */: + case 18 /* OpenBracketToken */: + case 24 /* LessThanToken */: + case 87 /* NewKeyword */: return true; - case 15 /* OpenParenToken */: - return lookAhead(function () { - nextToken(); - return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - }); + case 16 /* OpenParenToken */: + return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } } - function parsePrimaryType() { + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { - parseExpected(18 /* CloseBracketToken */); - var node = createNode(137 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { + parseExpected(19 /* CloseBracketToken */); + var node = createNode(140 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionType() { - var type = parsePrimaryType(); - if (token === 43 /* BarToken */) { + function parseUnionTypeOrHigher() { + var type = parseArrayTypeOrHigher(); + if (token === 44 /* BarToken */) { var types = [type]; types.pos = type.pos; - while (parseOptional(43 /* BarToken */)) { - types.push(parsePrimaryType()); + while (parseOptional(44 /* BarToken */)) { + types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(139 /* UnionType */, type.pos); + var node = createNode(142 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } return type; } function isStartOfFunctionType() { - return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { + if (token === 24 /* LessThanToken */) { + return true; + } + return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 50 /* QuestionToken */ || token === 52 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { return true; } - if (isIdentifier() || isModifier(token)) { + if (token === 17 /* CloseParenToken */) { nextToken(); - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 32 /* EqualsGreaterThanToken */) { return true; } - if (token === 16 /* CloseParenToken */) { - nextToken(); - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - } } - return false; - }); + } + return false; } function parseType() { var savedYieldContext = inYieldContext(); @@ -3714,71 +4237,74 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionType(133 /* FunctionType */); + return parseFunctionOrConstructorType(136 /* FunctionType */); } - if (token === 86 /* NewKeyword */) { - return parseFunctionType(134 /* ConstructorType */); + if (token === 87 /* NewKeyword */) { + return parseFunctionOrConstructorType(137 /* ConstructorType */); } - return parseUnionType(); + return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(50 /* ColonToken */) ? parseType() : undefined; + return parseOptional(51 /* ColonToken */) ? parseType() : undefined; } function isStartOfExpression() { switch (token) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 15 /* OpenParenToken */: - case 17 /* OpenBracketToken */: - case 13 /* OpenBraceToken */: - case 81 /* FunctionKeyword */: - case 86 /* NewKeyword */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - case 23 /* LessThanToken */: - case 63 /* Identifier */: - case 108 /* YieldKeyword */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 11 /* TemplateHead */: + case 16 /* OpenParenToken */: + case 18 /* OpenBracketToken */: + case 14 /* OpenBraceToken */: + case 82 /* FunctionKeyword */: + case 87 /* NewKeyword */: + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: + case 46 /* ExclamationToken */: + case 73 /* DeleteKeyword */: + case 96 /* TypeOfKeyword */: + case 98 /* VoidKeyword */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: + case 24 /* LessThanToken */: + case 64 /* Identifier */: + case 109 /* YieldKeyword */: return true; default: + if (isBinaryOperator()) { + return true; + } return isIdentifier(); } } function isStartOfExpressionStatement() { - return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); + return token !== 14 /* OpenBraceToken */ && token !== 82 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression() { - var expr = parseAssignmentExpression(); - while (parseOptional(22 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression()); + var expr = parseAssignmentExpressionOrHigher(); + while (parseOptional(23 /* CommaToken */)) { + expr = makeBinaryExpression(expr, 23 /* CommaToken */, parseAssignmentExpressionOrHigher()); } return expr; } function parseInitializer(inParameter) { - if (token !== 51 /* EqualsToken */) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) { + if (token !== 52 /* EqualsToken */) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { return undefined; } } - parseExpected(51 /* EqualsToken */); - return parseAssignmentExpression(); + parseExpected(52 /* EqualsToken */); + return parseAssignmentExpressionOrHigher(); } - function parseAssignmentExpression() { + function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { return parseYieldExpression(); } @@ -3786,38 +4312,39 @@ var ts; if (arrowExpression) { return arrowExpression; } - var expr = parseConditionalExpression(); - if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { + var expr = parseBinaryExpressionOrHigher(0); + if (expr.kind === 64 /* Identifier */ && token === 32 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } - if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) { + if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { var operator = token; nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpression()); + return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); } - return expr; + return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 108 /* YieldKeyword */) { + if (token === 109 /* YieldKeyword */) { if (inYieldContext()) { return true; } if (inStrictModeContext()) { return true; } - return lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - }); + return lookAhead(nextTokenIsIdentifierOnSameLine); } return false; } - function parseYieldExpression() { - var node = createNode(160 /* YieldExpression */); + function nextTokenIsIdentifierOnSameLine() { nextToken(); - if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.expression = parseAssignmentExpression(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(166 /* YieldExpression */); + nextToken(); + if (!scanner.hasPrecedingLineBreak() && (token === 35 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } else { @@ -3825,346 +4352,411 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(31 /* EqualsGreaterThanToken */); - var parameter = createNode(123 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(157 /* ArrowFunction */, identifier.pos); + var parameter = createNode(124 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - var parameters = []; - parameters.push(parameter); - parameters.pos = parameter.pos; - parameters.end = parameter.end; - var signature = { parameters: parameters }; - return parseArrowExpressionTail(identifier.pos, signature); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + parseExpected(32 /* EqualsGreaterThanToken */); + node.body = parseArrowFunctionExpressionBody(); + return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0 /* False */) { return undefined; } - var pos = getNodePos(); - if (triState === 1 /* True */) { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { - return parseArrowExpressionTail(pos, sig); - } - else { - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode()); - } - } - var sig = tryParseSignatureIfArrowOrBraceFollows(); - if (sig) { - parseExpected(31 /* EqualsGreaterThanToken */); - return parseArrowExpressionTail(pos, sig); - } - else { + var arrowFunction = triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpressionHead(true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { return undefined; } + if (parseExpected(32 /* EqualsGreaterThanToken */) || token === 14 /* OpenBraceToken */) { + arrowFunction.body = parseArrowFunctionExpressionBody(); + } + else { + arrowFunction.body = parseIdentifier(); + } + return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return lookAhead(function () { - var first = token; - var second = nextToken(); - if (first === 15 /* OpenParenToken */) { - if (second === 16 /* CloseParenToken */) { - var third = nextToken(); - switch (third) { - case 31 /* EqualsGreaterThanToken */: - case 50 /* ColonToken */: - case 13 /* OpenBraceToken */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - if (second === 20 /* DotDotDotToken */) { - return 1 /* True */; - } - if (!isIdentifier()) { - return 0 /* False */; - } - if (nextToken() === 50 /* ColonToken */) { - return 1 /* True */; - } - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 23 /* LessThanToken */); - if (!isIdentifier()) { - return 0 /* False */; - } - return 2 /* Unknown */; - } - }); + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 31 /* EqualsGreaterThanToken */) { + if (token === 32 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } - function tryParseSignatureIfArrowOrBraceFollows() { - return tryParse(function () { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { - return sig; + function isParenthesizedArrowFunctionExpressionWorker() { + var first = token; + var second = nextToken(); + if (first === 16 /* OpenParenToken */) { + if (second === 17 /* CloseParenToken */) { + var third = nextToken(); + switch (third) { + case 32 /* EqualsGreaterThanToken */: + case 51 /* ColonToken */: + case 14 /* OpenBraceToken */: + return 1 /* True */; + default: + return 0 /* False */; + } } - return undefined; - }); - } - function parseArrowExpressionTail(pos, sig) { - var body; - if (token === 13 /* OpenBraceToken */) { - body = parseFunctionBlock(false, false); - } - else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { - body = parseFunctionBlock(false, true); + if (second === 21 /* DotDotDotToken */) { + return 1 /* True */; + } + if (!isIdentifier()) { + return 0 /* False */; + } + if (nextToken() === 51 /* ColonToken */) { + return 1 /* True */; + } + return 2 /* Unknown */; } else { - body = parseAssignmentExpression(); + ts.Debug.assert(first === 24 /* LessThanToken */); + if (!isIdentifier()) { + return 0 /* False */; + } + return 2 /* Unknown */; } - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body); } - function parseConditionalExpression() { - var expr = parseBinaryOperators(parseUnaryExpression(), 0); - while (parseOptional(49 /* QuestionToken */)) { - var node = createNode(157 /* ConditionalExpression */, expr.pos); - node.condition = expr; - node.whenTrue = allowInAnd(parseAssignmentExpression); - parseExpected(50 /* ColonToken */); - node.whenFalse = parseAssignmentExpression(); - expr = finishNode(node); + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(157 /* ArrowFunction */); + fillSignature(51 /* ColonToken */, false, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; } - return expr; + if (!allowAmbiguity && token !== 32 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + return undefined; + } + return node; } - function parseBinaryOperators(expr, minPrecedence) { + function parseArrowFunctionExpressionBody() { + if (token === 14 /* OpenBraceToken */) { + return parseFunctionBlock(false, false); + } + if (isStatement(true) && !isStartOfExpressionStatement() && token !== 82 /* FunctionKeyword */) { + return parseFunctionBlock(false, true); + } + return parseAssignmentExpressionOrHigher(); + } + function parseConditionalExpressionRest(leftOperand) { + if (!parseOptional(50 /* QuestionToken */)) { + return leftOperand; + } + var node = createNode(164 /* ConditionalExpression */, leftOperand.pos); + node.condition = leftOperand; + node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(51 /* ColonToken */); + node.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); - var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) { - var operator = token; - nextToken(); - expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); - continue; + var newPrecedence = getBinaryOperatorPrecedence(); + if (newPrecedence <= precedence) { + break; } - return expr; + if (token === 85 /* InKeyword */ && inDisallowInContext()) { + break; + } + var operator = token; + nextToken(); + leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); } + return leftOperand; } - function getOperatorPrecedence() { + function isBinaryOperator() { + if (inDisallowInContext() && token === 85 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { switch (token) { - case 48 /* BarBarToken */: + case 49 /* BarBarToken */: return 1; - case 47 /* AmpersandAmpersandToken */: + case 48 /* AmpersandAmpersandToken */: return 2; - case 43 /* BarToken */: + case 44 /* BarToken */: return 3; - case 44 /* CaretToken */: + case 45 /* CaretToken */: return 4; - case 42 /* AmpersandToken */: + case 43 /* AmpersandToken */: return 5; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: + case 28 /* EqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: return 6; - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: - case 85 /* InstanceOfKeyword */: - case 84 /* InKeyword */: + case 24 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 26 /* LessThanEqualsToken */: + case 27 /* GreaterThanEqualsToken */: + case 86 /* InstanceOfKeyword */: + case 85 /* InKeyword */: return 7; - case 39 /* LessThanLessThanToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: + case 40 /* LessThanLessThanToken */: + case 41 /* GreaterThanGreaterThanToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 32 /* PlusToken */: - case 33 /* MinusToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: return 9; - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: return 10; } - return undefined; + return -1; } function makeBinaryExpression(left, operator, right) { - var node = createNode(156 /* BinaryExpression */, left.pos); + var node = createNode(163 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; return finishNode(node); } - function parseUnaryExpression() { - var pos = getNodePos(); + function parsePrefixUnaryExpression() { + var node = createNode(161 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(158 /* DeleteExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(159 /* TypeOfExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(160 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { switch (token) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - var operator = token; - nextToken(); - return makeUnaryExpression(154 /* PrefixOperator */, pos, operator, parseUnaryExpression()); - case 23 /* LessThanToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: + case 46 /* ExclamationToken */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: + return parsePrefixUnaryExpression(); + case 73 /* DeleteKeyword */: + return parseDeleteExpression(); + case 96 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 98 /* VoidKeyword */: + return parseVoidExpression(); + case 24 /* LessThanToken */: return parseTypeAssertion(); + default: + return parsePostfixExpressionOrHigher(); } - var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; - if (illegalUsageOfSuperKeyword) { - error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - } - var expr = parseCallAndAccess(primaryExpression, false); - ts.Debug.assert(isLeftHandSideExpression(expr)); - if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var operator = token; + } + function parsePostfixExpressionOrHigher() { + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(isLeftHandSideExpression(expression)); + if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(162 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; nextToken(); - expr = makeUnaryExpression(155 /* PostfixOperator */, expr.pos, operator, expr); + return finishNode(node); } - return expr; + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 90 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + return expression; + } + var node = createNode(149 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + parseExpected(20 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); } function parseTypeAssertion() { - var node = createNode(150 /* TypeAssertion */); - parseExpected(23 /* LessThanToken */); + var node = createNode(154 /* TypeAssertionExpression */); + parseExpected(24 /* LessThanToken */); node.type = parseType(); - parseExpected(24 /* GreaterThanToken */); - node.operand = parseUnaryExpression(); + parseExpected(25 /* GreaterThanToken */); + node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function makeUnaryExpression(kind, pos, operator, operand) { - var node = createNode(kind, pos); - node.operator = operator; - node.operand = operand; - return finishNode(node); - } - function parseCallAndAccess(expr, inNewExpression) { + function parseMemberExpressionRest(expression) { while (true) { var dotOrBracketStart = scanner.getTokenPos(); - if (parseOptional(19 /* DotToken */)) { - var propertyAccess = createNode(145 /* PropertyAccess */, expr.pos); - var id; - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord); - }); - if (matchesPattern) { - errorAtPos(dotOrBracketStart + 1, 0, ts.Diagnostics.Identifier_expected); - id = createMissingNode(); - } - } - propertyAccess.left = expr; - propertyAccess.right = id || parseIdentifierName(); - expr = finishNode(propertyAccess); + if (parseOptional(20 /* DotToken */)) { + var propertyAccess = createNode(149 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); continue; } - if (parseOptional(17 /* OpenBracketToken */)) { - var indexedAccess = createNode(146 /* IndexedAccess */, expr.pos); - indexedAccess.object = expr; - if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { - indexedAccess.index = createMissingNode(); - } - else { - indexedAccess.index = allowInAnd(parseExpression); - if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) { - var literal = indexedAccess.index; + if (parseOptional(18 /* OpenBracketToken */)) { + var indexedAccess = createNode(150 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + if (token !== 19 /* CloseBracketToken */) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } - parseExpected(18 /* CloseBracketToken */); } - expr = finishNode(indexedAccess); + parseExpected(19 /* CloseBracketToken */); + expression = finishNode(indexedAccess); continue; } - if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(147 /* CallExpression */, expr.pos); - callExpr.func = expr; - if (token === 23 /* LessThanToken */) { - if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) - return expr; - } - else { - parseExpected(15 /* OpenParenToken */); - } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); - expr = finishNode(callExpr); + if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { + var tagExpression = createNode(153 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + expression = finishNode(tagExpression); continue; } - if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { - var tagExpression = createNode(149 /* TaggedTemplateExpression */, expr.pos); - tagExpression.tag = expr; - tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); - expr = finishNode(tagExpression); - continue; - } - return expr; + return expression; } } - function parseTypeArgumentsAndOpenParen() { - var result = parseTypeArguments(); - parseExpected(15 /* OpenParenToken */); + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 24 /* LessThanToken */) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(151 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 16 /* OpenParenToken */) { + var callExpr = createNode(151 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(16 /* OpenParenToken */); + var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(17 /* CloseParenToken */); return result; } - function parseTypeArguments() { - return parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); - } - function parseSingleTypeArgument() { - if (token === 22 /* CommaToken */) { - return createNode(120 /* Missing */); + function parseTypeArgumentsInExpression() { + if (!parseOptional(24 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + if (!parseExpected(25 /* GreaterThanToken */)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 16 /* OpenParenToken */: + case 20 /* DotToken */: + case 17 /* CloseParenToken */: + case 19 /* CloseBracketToken */: + case 51 /* ColonToken */: + case 22 /* SemicolonToken */: + case 23 /* CommaToken */: + case 50 /* QuestionToken */: + case 28 /* EqualsEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: + case 48 /* AmpersandAmpersandToken */: + case 49 /* BarBarToken */: + case 45 /* CaretToken */: + case 43 /* AmpersandToken */: + case 44 /* BarToken */: + case 15 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + return true; + default: + return false; } - return parseType(); } function parsePrimaryExpression() { switch (token) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: return parseTokenNode(); - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 15 /* OpenParenToken */: - return parseParenExpression(); - case 17 /* OpenBracketToken */: - return parseArrayLiteral(); - case 13 /* OpenBraceToken */: - return parseObjectLiteral(); - case 81 /* FunctionKeyword */: + case 16 /* OpenParenToken */: + return parseParenthesizedExpression(); + case 18 /* OpenBracketToken */: + return parseArrayLiteralExpression(); + case 14 /* OpenBraceToken */: + return parseObjectLiteralExpression(); + case 82 /* FunctionKeyword */: return parseFunctionExpression(); - case 86 /* NewKeyword */: + case 87 /* NewKeyword */: return parseNewExpression(); - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - if (reScanSlashToken() === 8 /* RegularExpressionLiteral */) { + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 10 /* TemplateHead */: + case 11 /* TemplateHead */: return parseTemplateExpression(); - default: - if (isIdentifier()) { - return parseIdentifier(); - } } - error(ts.Diagnostics.Expression_expected); - return createMissingNode(); + return parseIdentifier(ts.Diagnostics.Expression_expected); } - function parseParenExpression() { - var node = createNode(151 /* ParenExpression */); - parseExpected(15 /* OpenParenToken */); + function parseParenthesizedExpression() { + var node = createNode(155 /* ParenthesizedExpression */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression() { - return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression(); + return token === 23 /* CommaToken */ ? createNode(167 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArrayLiteralElement() { return parseAssignmentExpressionOrOmittedExpression(); @@ -4172,104 +4764,82 @@ var ts; function parseArgumentExpression() { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral() { - var node = createNode(141 /* ArrayLiteral */); - parseExpected(17 /* OpenBracketToken */); + function parseArrayLiteralExpression() { + var node = createNode(147 /* ArrayLiteralExpression */); + parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; - node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement); - parseExpected(18 /* CloseBracketToken */); + node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArrayLiteralElement); + parseExpected(19 /* CloseBracketToken */); return finishNode(node); } - function parsePropertyAssignment() { - var nodePos = scanner.getStartPos(); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var initialToken = token; + if (parseContextualModifier(114 /* GetKeyword */) || parseContextualModifier(118 /* SetKeyword */)) { + var kind = initialToken === 114 /* GetKeyword */ ? 130 /* GetAccessor */ : 131 /* SetAccessor */; + return parseAccessorDeclaration(kind, fullStart, undefined); + } + var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var node; - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body); - return finishNode(node); + if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return parseMethodDeclaration(fullStart, undefined, asteriskToken, propertyName, undefined, true); } - var flags = 0; - if (token === 49 /* QuestionToken */) { - flags |= 4 /* QuestionMark */; - nextToken(); - } - if ((token === 22 /* CommaToken */ || token === 14 /* CloseBraceToken */) && tokenIsIdentifier) { - node = createNode(144 /* ShorthandPropertyAssignment */, nodePos); - node.name = propertyName; + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(205 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + return finishNode(shorthandDeclaration); } else { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - parseExpected(50 /* ColonToken */); - node.initializer = allowInAnd(parseAssignmentExpression); + var propertyAssignment = createNode(204 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(51 /* ColonToken */); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); } - node.flags = flags; - return finishNode(node); } - function parseObjectLiteralMember() { - var initialPos = getNodePos(); - var initialToken = token; - if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { - var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; - return parseMemberAccessorDeclaration(kind, initialPos, undefined); - } - return parsePropertyAssignment(); - } - function parseObjectLiteral() { - var node = createNode(142 /* ObjectLiteral */); - parseExpected(13 /* OpenBraceToken */); + function parseObjectLiteralExpression() { + var node = createNode(148 /* ObjectLiteralExpression */); + parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember); - parseExpected(14 /* CloseBraceToken */); + node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement); + parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - var pos = getNodePos(); - parseExpected(81 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body); + var node = createNode(156 /* FunctionExpression */); + parseExpected(82 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); + fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); + node.body = parseFunctionBlock(!!node.asteriskToken, false); + return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } - function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) { - var node = createNode(kind, pos); - node.asteriskToken = asteriskToken; - node.name = name; - node.typeParameters = sig.typeParameters; - node.parameters = sig.parameters; - node.type = sig.type; - node.body = body; - return finishNode(node); - } function parseNewExpression() { - var node = createNode(148 /* NewExpression */); - parseExpected(86 /* NewKeyword */); - node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); + var node = createNode(152 /* NewExpression */); + parseExpected(87 /* NewKeyword */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 16 /* OpenParenToken */) { + node.arguments = parseArgumentList(); } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(162 /* Block */); - if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { + function parseBlock(kind, ignoreMissingOpenBrace, checkForStrictMode) { + var node = createNode(kind); + if (parseExpected(14 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -4279,58 +4849,57 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 187 /* FunctionBlock */; + var block = parseBlock(169 /* Block */, ignoreMissingOpenBrace, true); setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(164 /* EmptyStatement */); - parseExpected(21 /* SemicolonToken */); + var node = createNode(171 /* EmptyStatement */); + parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(166 /* IfStatement */); - parseExpected(82 /* IfKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(173 /* IfStatement */); + parseExpected(83 /* IfKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(75 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(167 /* DoStatement */); - parseExpected(73 /* DoKeyword */); + var node = createNode(174 /* DoStatement */); + parseExpected(74 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); + parseExpected(99 /* WhileKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseOptional(21 /* SemicolonToken */); + parseExpected(17 /* CloseParenToken */); + parseOptional(22 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(168 /* WhileStatement */); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(175 /* WhileStatement */); + parseExpected(99 /* WhileKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInStatement() { var pos = getNodePos(); - parseExpected(80 /* ForKeyword */); - parseExpected(15 /* OpenParenToken */); - if (token !== 21 /* SemicolonToken */) { - if (parseOptional(96 /* VarKeyword */)) { + parseExpected(81 /* ForKeyword */); + parseExpected(16 /* OpenParenToken */); + if (token !== 22 /* SemicolonToken */) { + if (parseOptional(97 /* VarKeyword */)) { var declarations = disallowInAnd(parseVariableDeclarationList); } - else if (parseOptional(102 /* LetKeyword */)) { + else if (parseOptional(103 /* LetKeyword */)) { var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 2048 /* Let */); } - else if (parseOptional(68 /* ConstKeyword */)) { + else if (parseOptional(69 /* ConstKeyword */)) { var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 4096 /* Const */); } else { @@ -4338,8 +4907,8 @@ var ts; } } var forOrForInStatement; - if (parseOptional(84 /* InKeyword */)) { - var forInStatement = createNode(170 /* ForInStatement */, pos); + if (parseOptional(85 /* InKeyword */)) { + var forInStatement = createNode(177 /* ForInStatement */, pos); if (declarations) { forInStatement.declarations = declarations; } @@ -4347,26 +4916,26 @@ var ts; forInStatement.variable = varOrInit; } forInStatement.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); forOrForInStatement = forInStatement; } else { - var forStatement = createNode(169 /* ForStatement */, pos); + var forStatement = createNode(176 /* ForStatement */, pos); if (declarations) { forStatement.declarations = declarations; } if (varOrInit) { forStatement.initializer = varOrInit; } - parseExpected(21 /* SemicolonToken */); - if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) { + parseExpected(22 /* SemicolonToken */); + if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(21 /* SemicolonToken */); - if (token !== 16 /* CloseParenToken */) { + parseExpected(22 /* SemicolonToken */); + if (token !== 17 /* CloseParenToken */) { forStatement.iterator = allowInAnd(parseExpression); } - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); forOrForInStatement = forStatement; } forOrForInStatement.statement = parseStatement(); @@ -4374,7 +4943,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); + parseExpected(kind === 179 /* BreakStatement */ ? 65 /* BreakKeyword */ : 70 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -4382,8 +4951,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(173 /* ReturnStatement */); - parseExpected(88 /* ReturnKeyword */); + var node = createNode(180 /* ReturnStatement */); + parseExpected(89 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -4391,235 +4960,283 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(174 /* WithStatement */); - parseExpected(99 /* WithKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(181 /* WithStatement */); + parseExpected(100 /* WithKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(176 /* CaseClause */); - parseExpected(65 /* CaseKeyword */); + var node = createNode(200 /* CaseClause */); + parseExpected(66 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(50 /* ColonToken */); + parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(177 /* DefaultClause */); - parseExpected(71 /* DefaultKeyword */); - parseExpected(50 /* ColonToken */); + var node = createNode(201 /* DefaultClause */); + parseExpected(72 /* DefaultKeyword */); + parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 66 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(175 /* SwitchStatement */); - parseExpected(90 /* SwitchKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(182 /* SwitchStatement */); + parseExpected(91 /* SwitchKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseExpected(13 /* OpenBraceToken */); + parseExpected(17 /* CloseParenToken */); + parseExpected(14 /* OpenBraceToken */); node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseThrowStatement() { - var node = createNode(179 /* ThrowStatement */); - parseExpected(92 /* ThrowKeyword */); - if (scanner.hasPrecedingLineBreak()) { - error(ts.Diagnostics.Line_break_not_permitted_here); - } - node.expression = allowInAnd(parseExpression); + var node = createNode(184 /* ThrowStatement */); + parseExpected(93 /* ThrowKeyword */); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(180 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */); - if (token === 66 /* CatchKeyword */) { - node.catchBlock = parseCatchBlock(); - } - if (token === 79 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */); - } - if (!(node.catchBlock || node.finallyBlock)) { - error(ts.Diagnostics.catch_or_finally_expected); - } + var node = createNode(185 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(95 /* TryKeyword */); + node.catchClause = token === 67 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.finallyBlock = !node.catchClause || token === 80 /* FinallyKeyword */ ? parseTokenAndBlock(80 /* FinallyKeyword */) : undefined; return finishNode(node); } - function parseTokenAndBlock(token, kind) { + function parseTokenAndBlock(token) { var pos = getNodePos(); parseExpected(token); - var result = parseBlock(false, false); - result.kind = kind; + var result = parseBlock(token === 95 /* TryKeyword */ ? 186 /* TryBlock */ : 187 /* FinallyBlock */, false, false); result.pos = pos; return result; } - function parseCatchBlock() { - var pos = getNodePos(); - parseExpected(66 /* CatchKeyword */); - parseExpected(15 /* OpenParenToken */); - var variable = parseIdentifier(); - var typeAnnotation = parseTypeAnnotation(); - parseExpected(16 /* CloseParenToken */); - var result = parseBlock(false, false); - result.kind = 182 /* CatchBlock */; - result.pos = pos; - result.variable = variable; - result.type = typeAnnotation; - return result; + function parseCatchClause() { + var result = createNode(203 /* CatchClause */); + parseExpected(67 /* CatchKeyword */); + parseExpected(16 /* OpenParenToken */); + result.name = parseIdentifier(); + result.type = parseTypeAnnotation(); + parseExpected(17 /* CloseParenToken */); + result.block = parseBlock(169 /* Block */, false, false); + return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(184 /* DebuggerStatement */); - parseExpected(70 /* DebuggerKeyword */); + var node = createNode(188 /* DebuggerStatement */); + parseExpected(71 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } - function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); - } - function parseLabeledStatement() { - var node = createNode(178 /* LabeledStatement */); - node.label = parseIdentifier(); - parseExpected(50 /* ColonToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseExpressionStatement() { - var node = createNode(165 /* ExpressionStatement */); - node.expression = allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); + function parseExpressionOrLabeledStatement() { + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 64 /* Identifier */ && parseOptional(51 /* ColonToken */)) { + var labeledStatement = createNode(183 /* LabeledStatement */, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(172 /* ExpressionStatement */, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } } function isStatement(inErrorRecovery) { switch (token) { - case 21 /* SemicolonToken */: + case 22 /* SemicolonToken */: return !inErrorRecovery; - case 13 /* OpenBraceToken */: - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 81 /* FunctionKeyword */: - case 82 /* IfKeyword */: - case 73 /* DoKeyword */: - case 98 /* WhileKeyword */: - case 80 /* ForKeyword */: - case 69 /* ContinueKeyword */: - case 64 /* BreakKeyword */: - case 88 /* ReturnKeyword */: - case 99 /* WithKeyword */: - case 90 /* SwitchKeyword */: - case 92 /* ThrowKeyword */: - case 94 /* TryKeyword */: - case 70 /* DebuggerKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: + case 14 /* OpenBraceToken */: + case 97 /* VarKeyword */: + case 103 /* LetKeyword */: + case 82 /* FunctionKeyword */: + case 83 /* IfKeyword */: + case 74 /* DoKeyword */: + case 99 /* WhileKeyword */: + case 81 /* ForKeyword */: + case 70 /* ContinueKeyword */: + case 65 /* BreakKeyword */: + case 89 /* ReturnKeyword */: + case 100 /* WithKeyword */: + case 91 /* SwitchKeyword */: + case 93 /* ThrowKeyword */: + case 95 /* TryKeyword */: + case 71 /* DebuggerKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: return true; - case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + case 69 /* ConstKeyword */: + var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 101 /* InterfaceKeyword */: - case 67 /* ClassKeyword */: - case 114 /* ModuleKeyword */: - case 75 /* EnumKeyword */: - case 119 /* TypeKeyword */: + case 102 /* InterfaceKeyword */: + case 68 /* ClassKeyword */: + case 115 /* ModuleKeyword */: + case 76 /* EnumKeyword */: + case 120 /* TypeKeyword */: if (isDeclarationStart()) { return false; } - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } default: return isStartOfExpression(); } } + function nextTokenIsEnumKeyword() { + nextToken(); + return token === 76 /* EnumKeyword */; + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + } function parseStatement() { switch (token) { - case 13 /* OpenBraceToken */: - return parseBlock(false, false); - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 68 /* ConstKeyword */: + case 14 /* OpenBraceToken */: + return parseBlock(169 /* Block */, false, false); + case 97 /* VarKeyword */: + case 69 /* ConstKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined); - case 81 /* FunctionKeyword */: + case 82 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), undefined); - case 21 /* SemicolonToken */: + case 22 /* SemicolonToken */: return parseEmptyStatement(); - case 82 /* IfKeyword */: + case 83 /* IfKeyword */: return parseIfStatement(); - case 73 /* DoKeyword */: + case 74 /* DoKeyword */: return parseDoStatement(); - case 98 /* WhileKeyword */: + case 99 /* WhileKeyword */: return parseWhileStatement(); - case 80 /* ForKeyword */: + case 81 /* ForKeyword */: return parseForOrForInStatement(); - case 69 /* ContinueKeyword */: - return parseBreakOrContinueStatement(171 /* ContinueStatement */); - case 64 /* BreakKeyword */: - return parseBreakOrContinueStatement(172 /* BreakStatement */); - case 88 /* ReturnKeyword */: + case 70 /* ContinueKeyword */: + return parseBreakOrContinueStatement(178 /* ContinueStatement */); + case 65 /* BreakKeyword */: + return parseBreakOrContinueStatement(179 /* BreakStatement */); + case 89 /* ReturnKeyword */: return parseReturnStatement(); - case 99 /* WithKeyword */: + case 100 /* WithKeyword */: return parseWithStatement(); - case 90 /* SwitchKeyword */: + case 91 /* SwitchKeyword */: return parseSwitchStatement(); - case 92 /* ThrowKeyword */: + case 93 /* ThrowKeyword */: return parseThrowStatement(); - case 94 /* TryKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: + case 95 /* TryKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: return parseTryStatement(); - case 70 /* DebuggerKeyword */: + case 71 /* DebuggerKeyword */: return parseDebuggerStatement(); + case 103 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), undefined); + } default: - return isLabel() ? parseLabeledStatement() : parseExpressionStatement(); + return parseExpressionOrLabeledStatement(); } } function parseFunctionBlockOrSemicolon(isGenerator) { - if (token === 13 /* OpenBraceToken */) { + if (token === 14 /* OpenBraceToken */) { return parseFunctionBlock(isGenerator, false); } - if (canParseSemicolon()) { - parseSemicolon(); - return undefined; + parseSemicolon(ts.Diagnostics.or_expected); + return undefined; + } + function parseBindingElement(context) { + if (context === 11 /* ArrayBindingElements */ && token === 23 /* CommaToken */) { + return createNode(167 /* OmittedExpression */); } - error(ts.Diagnostics.Block_or_expected); + var node = createNode(146 /* BindingElement */); + if (context === 10 /* ObjectBindingElements */) { + var id = parsePropertyName(); + if (id.kind === 64 /* Identifier */ && token !== 51 /* ColonToken */) { + node.name = id; + } + else { + parseExpected(51 /* ColonToken */); + node.propertyName = id; + node.name = parseIdentifierOrPattern(); + } + } + else { + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseInitializer(false); + return finishNode(node); + } + function parseBindingList(context) { + return parseDelimitedList(context, function () { return parseBindingElement(context); }); + } + function parseObjectBindingPattern() { + var node = createNode(144 /* ObjectBindingPattern */); + parseExpected(14 /* OpenBraceToken */); + node.elements = parseBindingList(10 /* ObjectBindingElements */); + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(145 /* ArrayBindingPattern */); + parseExpected(18 /* OpenBracketToken */); + node.elements = parseBindingList(11 /* ArrayBindingElements */); + parseExpected(19 /* CloseBracketToken */); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 18 /* OpenBracketToken */) { + return parseArrayBindingPattern(); + } + if (token === 14 /* OpenBraceToken */) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(185 /* VariableDeclaration */); - node.name = parseIdentifier(); + var node = createNode(189 /* VariableDeclaration */); + node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); node.initializer = parseInitializer(false); return finishNode(node); } - function setFlag(array, flag) { - for (var i = 0, n = array.length; i < n; i++) { - array[i].flags |= flag; + function setFlag(nodes, flag) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + node.flags |= flag; + if (node.name && ts.isBindingPattern(node.name)) { + setFlag(node.name.elements, flag); + } } - return array; + return nodes; } function parseVariableDeclarationList() { return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); } function parseVariableStatement(fullStart, modifiers) { - var node = createNode(163 /* VariableStatement */, fullStart); + var node = createNode(170 /* VariableStatement */, fullStart); setModifiers(node, modifiers); - if (token === 102 /* LetKeyword */) { + if (token === 103 /* LetKeyword */) { node.flags |= 2048 /* Let */; } - else if (token === 68 /* ConstKeyword */) { + else if (token === 69 /* ConstKeyword */) { node.flags |= 4096 /* Const */; } else { - ts.Debug.assert(token === 96 /* VarKeyword */); + ts.Debug.assert(token === 97 /* VarKeyword */); } nextToken(); node.declarations = allowInAnd(parseVariableDeclarationList); @@ -4628,89 +5245,88 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(186 /* FunctionDeclaration */, fullStart); + var node = createNode(190 /* FunctionDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(81 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + parseExpected(82 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = parseIdentifier(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node); + fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken); return finishNode(node); } function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(126 /* Constructor */, pos); + var node = createNode(129 /* Constructor */, pos); setModifiers(node, modifiers); - parseExpected(111 /* ConstructorKeyword */); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + parseExpected(112 /* ConstructorKeyword */); + fillSignature(51 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } - function parsePropertyMemberDeclaration(fullStart, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, requireBlock) { + var method = createNode(128 /* MethodDeclaration */, fullStart); + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + fillSignature(51 /* ColonToken */, !!asteriskToken, false, method); + method.body = requireBlock ? parseFunctionBlock(!!asteriskToken, false) : parseFunctionBlockOrSemicolon(!!asteriskToken); + return finishNode(method); + } + function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); var name = parsePropertyName(); - if (parseOptional(49 /* QuestionToken */)) { - flags |= 4 /* QuestionMark */; - } - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); - setModifiers(method, modifiers); - if (flags) { - method.flags = flags; - } - method.asteriskToken = asteriskToken; - method.name = name; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken); - return finishNode(method); + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, false); } else { - var property = createNode(124 /* Property */, fullStart); + var property = createNode(126 /* PropertyDeclaration */, fullStart); setModifiers(property, modifiers); - if (flags) { - property.flags = flags; - } property.name = name; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(function () { return parseInitializer(false); }); + property.initializer = allowInAnd(parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } } - function parseMemberAccessorDeclaration(kind, fullStart, modifiers) { + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, modifiers) { var node = createNode(kind, fullStart); setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(51 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } function isClassMemberStart() { var idToken; - while (isModifier(token)) { + while (ts.isModifier(token)) { idToken = token; nextToken(); } - if (token === 34 /* AsteriskToken */) { + if (token === 35 /* AsteriskToken */) { return true; } - if (isPropertyName()) { + if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 17 /* OpenBracketToken */) { + if (token === 18 /* OpenBracketToken */) { return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 118 /* SetKeyword */ || idToken === 114 /* GetKeyword */) { return true; } switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 50 /* ColonToken */: - case 51 /* EqualsToken */: - case 49 /* QuestionToken */: + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + case 51 /* ColonToken */: + case 52 /* EqualsToken */: + case 50 /* QuestionToken */: return true; default: return canParseSemicolon(); @@ -4722,246 +5338,271 @@ var ts; var flags = 0; var modifiers; while (true) { - var modifierStart = scanner.getTokenPos(); + var modifierStart = scanner.getStartPos(); var modifierKind = token; if (!parseAnyContextualModifier()) { break; } if (!modifiers) { modifiers = []; + modifiers.pos = modifierStart; } flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } if (modifiers) { modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); } return modifiers; } - function parseClassMemberDeclaration() { + function parseClassElement() { var fullStart = getNodePos(); var modifiers = parseModifiers(); - if (parseContextualModifier(113 /* GetKeyword */)) { - return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); + if (parseContextualModifier(114 /* GetKeyword */)) { + return parseAccessorDeclaration(130 /* GetAccessor */, fullStart, modifiers); } - if (parseContextualModifier(117 /* SetKeyword */)) { - return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); + if (parseContextualModifier(118 /* SetKeyword */)) { + return parseAccessorDeclaration(131 /* SetAccessor */, fullStart, modifiers); } - if (token === 111 /* ConstructorKeyword */) { + if (token === 112 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) { - return parsePropertyMemberDeclaration(fullStart, modifiers); + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, modifiers); } - if (token === 17 /* OpenBracketToken */) { - return parseIndexSignatureMember(fullStart, modifiers); + if (isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || token === 35 /* AsteriskToken */ || token === 18 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, modifiers); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(188 /* ClassDeclaration */, fullStart); + var node = createNode(191 /* ClassDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(67 /* ClassKeyword */); + parseExpected(68 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType(); - if (parseOptional(100 /* ImplementsKeyword */)) { - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - if (parseExpected(13 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(true); + if (parseExpected(14 /* OpenBraceToken */)) { node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers(); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.members = createMissingList(); } return finishNode(node); } - function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); + } + return undefined; } - function parseClassBaseType() { - return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + function parseHeritageClausesWorker() { + return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */) { + var node = createNode(202 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(8 /* TypeReferences */, parseTypeReference); + return finishNode(node); + } + return undefined; + } + function isHeritageClause() { + return token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(189 /* InterfaceDeclaration */, fullStart); + var node = createNode(192 /* InterfaceDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(101 /* InterfaceKeyword */); + parseExpected(102 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - if (parseOptional(77 /* ExtendsKeyword */)) { - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - node.members = parseObjectType(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(190 /* TypeAliasDeclaration */, fullStart); + var node = createNode(193 /* TypeAliasDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(119 /* TypeKeyword */); + parseExpected(120 /* TypeKeyword */); node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); + parseExpected(52 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(196 /* EnumMember */, scanner.getStartPos()); + var node = createNode(206 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(function () { return parseInitializer(false); }); + node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseAndCheckEnumDeclaration(fullStart, flags) { - var node = createNode(191 /* EnumDeclaration */, fullStart); - node.flags = flags; - if (flags & 4096 /* Const */) { - parseExpected(68 /* ConstKeyword */); - } - parseExpected(75 /* EnumKeyword */); + function parseEnumDeclaration(fullStart, modifiers) { + var node = createNode(194 /* EnumDeclaration */, fullStart); + setModifiers(node, modifiers); + parseExpected(76 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(13 /* OpenBraceToken */)) { + if (parseExpected(14 /* OpenBraceToken */)) { node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.members = createMissingList(); } return finishNode(node); } - function parseModuleBody() { - var node = createNode(193 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(13 /* OpenBraceToken */)) { + function parseModuleBlock() { + var node = createNode(196 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.statements = createMissingList(); } return finishNode(node); } - function parseInternalModuleTail(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; + function parseInternalModuleTail(fullStart, modifiers, flags) { + var node = createNode(195 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody(); + node.body = parseOptional(20 /* DotToken */) ? parseInternalModuleTail(getNodePos(), undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; - node.name = parseStringLiteral(); - node.body = parseModuleBody(); + function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { + var node = createNode(195 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, flags) { - parseExpected(114 /* ModuleKeyword */); - return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags); + function parseModuleDeclaration(fullStart, modifiers) { + parseExpected(115 /* ModuleKeyword */); + return token === 8 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + } + function isExternalModuleReference() { + return token === 116 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 16 /* OpenParenToken */; } function parseImportDeclaration(fullStart, modifiers) { - var node = createNode(194 /* ImportDeclaration */, fullStart); + var node = createNode(197 /* ImportDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(83 /* ImportKeyword */); + parseExpected(84 /* ImportKeyword */); node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); - var entityName = parseEntityName(false); - if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { - node.externalModuleName = parseStringLiteral(); - parseExpected(16 /* CloseParenToken */); - } - else { - node.entityName = entityName; - } + parseExpected(52 /* EqualsToken */); + node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } + function parseModuleReference() { + return isExternalModuleReference() ? parseExternalModuleReference() : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(199 /* ExternalModuleReference */); + parseExpected(116 /* RequireKeyword */); + parseExpected(16 /* OpenParenToken */); + node.expression = parseExpression(); + if (node.expression.kind === 8 /* StringLiteral */) { + internIdentifier(node.expression.text); + } + parseExpected(17 /* CloseParenToken */); + return finishNode(node); + } function parseExportAssignmentTail(fullStart, modifiers) { - var node = createNode(195 /* ExportAssignment */, fullStart); + var node = createNode(198 /* ExportAssignment */, fullStart); setModifiers(node, modifiers); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } + function isLetDeclaration() { + return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine); + } function isDeclarationStart() { switch (token) { - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 68 /* ConstKeyword */: - case 81 /* FunctionKeyword */: + case 97 /* VarKeyword */: + case 69 /* ConstKeyword */: + case 82 /* FunctionKeyword */: return true; - case 67 /* ClassKeyword */: - case 101 /* InterfaceKeyword */: - case 75 /* EnumKeyword */: - case 83 /* ImportKeyword */: - case 119 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); - case 114 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); - case 76 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); - case 112 /* DeclareKeyword */: - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - return lookAhead(function () { - nextToken(); - return isDeclarationStart(); - }); + case 103 /* LetKeyword */: + return isLetDeclaration(); + case 68 /* ClassKeyword */: + case 102 /* InterfaceKeyword */: + case 76 /* EnumKeyword */: + case 84 /* ImportKeyword */: + case 120 /* TypeKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 115 /* ModuleKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 77 /* ExportKeyword */: + return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart); + case 113 /* DeclareKeyword */: + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + return lookAhead(nextTokenIsDeclarationStart); } } + function isIdentifierOrKeyword() { + return token >= 64 /* Identifier */; + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function nextTokenIsIdentifierOrKeywordOrStringLiteral() { + nextToken(); + return isIdentifierOrKeyword() || token === 8 /* StringLiteral */; + } + function nextTokenIsEqualsTokenOrDeclarationStart() { + nextToken(); + return token === 52 /* EqualsToken */ || isDeclarationStart(); + } + function nextTokenIsDeclarationStart() { + nextToken(); + return isDeclarationStart(); + } function parseDeclaration() { var fullStart = getNodePos(); var modifiers = parseModifiers(); - if (token === 76 /* ExportKeyword */) { + if (token === 77 /* ExportKeyword */) { nextToken(); - if (parseOptional(51 /* EqualsToken */)) { + if (parseOptional(52 /* EqualsToken */)) { return parseExportAssignmentTail(fullStart, modifiers); } } - var flags = modifiers ? modifiers.flags : 0; - var result; switch (token) { - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - result = parseVariableStatement(fullStart, modifiers); - break; - case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); - if (isConstEnum) { - result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */); - } - else { - result = parseVariableStatement(fullStart, modifiers); - } - break; - case 81 /* FunctionKeyword */: - result = parseFunctionDeclaration(fullStart, modifiers); - break; - case 67 /* ClassKeyword */: - result = parseClassDeclaration(fullStart, modifiers); - break; - case 101 /* InterfaceKeyword */: - result = parseInterfaceDeclaration(fullStart, modifiers); - break; - case 119 /* TypeKeyword */: - result = parseTypeAliasDeclaration(fullStart, modifiers); - break; - case 75 /* EnumKeyword */: - result = parseAndCheckEnumDeclaration(fullStart, flags); - break; - case 114 /* ModuleKeyword */: - result = parseModuleDeclaration(fullStart, flags); - break; - case 83 /* ImportKeyword */: - result = parseImportDeclaration(fullStart, modifiers); - break; + case 97 /* VarKeyword */: + case 103 /* LetKeyword */: + case 69 /* ConstKeyword */: + return parseVariableStatement(fullStart, modifiers); + case 82 /* FunctionKeyword */: + return parseFunctionDeclaration(fullStart, modifiers); + case 68 /* ClassKeyword */: + return parseClassDeclaration(fullStart, modifiers); + case 102 /* InterfaceKeyword */: + return parseInterfaceDeclaration(fullStart, modifiers); + case 120 /* TypeKeyword */: + return parseTypeAliasDeclaration(fullStart, modifiers); + case 76 /* EnumKeyword */: + return parseEnumDeclaration(fullStart, modifiers); + case 115 /* ModuleKeyword */: + return parseModuleDeclaration(fullStart, modifiers); + case 84 /* ImportKeyword */: + return parseImportDeclaration(fullStart, modifiers); default: - error(ts.Diagnostics.Declaration_expected); + ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } - if (modifiers) { - result.modifiers = modifiers; - } - return result; } function isSourceElement(inErrorRecovery) { return isDeclarationStart() || isStatement(inErrorRecovery); @@ -4976,24 +5617,30 @@ var ts; return isDeclarationStart() ? parseDeclaration() : parseStatement(); } function processReferenceComments() { + var triviaScanner = ts.createScanner(languageVersion, false, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; - commentRanges = []; - token = scanner.scan(); - for (var i = 0; i < commentRanges.length; i++) { - var range = commentRanges[i]; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() }; var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { var fileReference = referencePathMatchResult.fileReference; - file.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnostic = referencePathMatchResult.diagnostic; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; if (fileReference) { referencedFiles.push(fileReference); } - if (diagnostic) { - errorAtPos(range.pos, range.end - range.pos, diagnostic); + if (diagnosticMessage) { + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); } } else { @@ -5001,7 +5648,7 @@ var ts; var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment); if (amdModuleNameMatchResult) { if (amdModuleName) { - errorAtPos(range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments); + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments)); } amdModuleName = amdModuleNameMatchResult[2]; } @@ -5012,91 +5659,59 @@ var ts; } } } - commentRanges = undefined; - return { - referencedFiles: referencedFiles, - amdDependencies: amdDependencies, - amdModuleName: amdModuleName - }; + sourceFile.referencedFiles = referencedFiles; + sourceFile.amdDependencies = amdDependencies; + sourceFile.amdModuleName = amdModuleName; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */ || node.kind === 198 /* ExportAssignment */ ? node : undefined; }); } var syntacticDiagnostics; function getSyntacticDiagnostics() { if (syntacticDiagnostics === undefined) { - if (file.parseDiagnostics.length > 0) { - syntacticDiagnostics = file.parseDiagnostics; + if (sourceFile.parseDiagnostics.length > 0) { + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); } else { - syntacticDiagnostics = file.grammarDiagnostics; - checkGrammar(sourceText, languageVersion, file); + checkGrammar(sourceText, languageVersion, sourceFile); + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); } } ts.Debug.assert(syntacticDiagnostics !== undefined); return syntacticDiagnostics; } - scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); - var rootNodeFlags = 0; - if (ts.fileExtensionIs(filename, ".d.ts")) { - rootNodeFlags = 1024 /* DeclarationFile */; - } - file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags); - file.filename = ts.normalizePath(filename); - file.text = sourceText; - file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - file.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - file.getLineStarts = getLineStarts; - file.getSyntacticDiagnostics = getSyntacticDiagnostics; - file.parseDiagnostics = []; - file.grammarDiagnostics = []; - file.semanticDiagnostics = []; - var referenceComments = processReferenceComments(); - file.referencedFiles = referenceComments.referencedFiles; - file.amdDependencies = referenceComments.amdDependencies; - file.amdModuleName = referenceComments.amdModuleName; - file.statements = parseList(0 /* SourceElements */, true, parseSourceElement); - file.externalModuleIndicator = getExternalModuleIndicator(); - file.nodeCount = nodeCount; - file.identifierCount = identifierCount; - file.version = version; - file.isOpen = isOpen; - file.languageVersion = languageVersion; - file.identifiers = identifiers; - return file; } ts.createSourceFile = createSourceFile; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 148 /* NewExpression */: - case 147 /* CallExpression */: - case 149 /* TaggedTemplateExpression */: - case 141 /* ArrayLiteral */: - case 151 /* ParenExpression */: - case 142 /* ObjectLiteral */: - case 152 /* FunctionExpression */: - case 63 /* Identifier */: - case 120 /* Missing */: - case 8 /* RegularExpressionLiteral */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 158 /* TemplateExpression */: - case 78 /* FalseKeyword */: - case 87 /* NullKeyword */: - case 91 /* ThisKeyword */: - case 93 /* TrueKeyword */: - case 89 /* SuperKeyword */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 152 /* NewExpression */: + case 151 /* CallExpression */: + case 153 /* TaggedTemplateExpression */: + case 147 /* ArrayLiteralExpression */: + case 155 /* ParenthesizedExpression */: + case 148 /* ObjectLiteralExpression */: + case 156 /* FunctionExpression */: + case 64 /* Identifier */: + case 9 /* RegularExpressionLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 165 /* TemplateExpression */: + case 79 /* FalseKeyword */: + case 88 /* NullKeyword */: + case 92 /* ThisKeyword */: + case 94 /* TrueKeyword */: + case 90 /* SuperKeyword */: return true; } } return false; } function isAssignmentOperator(token) { - return token >= 51 /* FirstAssignment */ && token <= 62 /* LastAssignment */; + return token >= 52 /* FirstAssignment */ && token <= 63 /* LastAssignment */; } function checkGrammar(sourceText, languageVersion, file) { var grammarDiagnostics = file.grammarDiagnostics; @@ -5111,7 +5726,7 @@ var ts; parent = node; if (!checkModifiers(node)) { var savedInFunctionBlock = inFunctionBlock; - if (node.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(node)) { inFunctionBlock = true; } var savedInAmbientContext = inAmbientContext; @@ -5136,67 +5751,85 @@ var ts; } function checkNode(node, nodeKind) { switch (nodeKind) { - case 153 /* ArrowFunction */: - case 129 /* CallSignature */: - case 134 /* ConstructorType */: - case 130 /* ConstructSignature */: - case 133 /* FunctionType */: - return checkAnyParsedSignature(node); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + case 157 /* ArrowFunction */: + case 132 /* CallSignature */: + case 137 /* ConstructorType */: + case 133 /* ConstructSignature */: + case 136 /* FunctionType */: + return checkAnySignatureDeclaration(node); + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: return checkBreakOrContinueStatement(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return checkCallOrNewExpression(node); - case 191 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 156 /* BinaryExpression */: return checkBinaryExpression(node); - case 182 /* CatchBlock */: return checkCatchBlock(node); - case 188 /* ClassDeclaration */: return checkClassDeclaration(node); - case 126 /* Constructor */: return checkConstructor(node); - case 195 /* ExportAssignment */: return checkExportAssignment(node); - case 170 /* ForInStatement */: return checkForInStatement(node); - case 169 /* ForStatement */: return checkForStatement(node); - case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 152 /* FunctionExpression */: return checkFunctionExpression(node); - case 127 /* GetAccessor */: return checkGetAccessor(node); - case 146 /* IndexedAccess */: return checkIndexedAccess(node); - case 131 /* IndexSignature */: return checkIndexSignature(node); - case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 178 /* LabeledStatement */: return checkLabeledStatement(node); - case 125 /* Method */: return checkMethod(node); - case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 142 /* ObjectLiteral */: return checkObjectLiteral(node); - case 6 /* NumericLiteral */: return checkNumericLiteral(node); - case 123 /* Parameter */: return checkParameter(node); - case 155 /* PostfixOperator */: return checkPostfixOperator(node); - case 154 /* PrefixOperator */: return checkPrefixOperator(node); - case 124 /* Property */: return checkProperty(node); - case 143 /* PropertyAssignment */: return checkPropertyAssignment(node); - case 173 /* ReturnStatement */: return checkReturnStatement(node); - case 128 /* SetAccessor */: return checkSetAccessor(node); - case 197 /* SourceFile */: return checkSourceFile(node); - case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); - case 175 /* SwitchStatement */: return checkSwitchStatement(node); - case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 138 /* TupleType */: return checkTupleType(node); - case 122 /* TypeParameter */: return checkTypeParameter(node); - case 132 /* TypeReference */: return checkTypeReference(node); - case 185 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 163 /* VariableStatement */: return checkVariableStatement(node); - case 174 /* WithStatement */: return checkWithStatement(node); - case 160 /* YieldExpression */: return checkYieldExpression(node); + case 194 /* EnumDeclaration */: return checkEnumDeclaration(node); + case 163 /* BinaryExpression */: return checkBinaryExpression(node); + case 146 /* BindingElement */: return checkBindingElement(node); + case 203 /* CatchClause */: return checkCatchClause(node); + case 191 /* ClassDeclaration */: return checkClassDeclaration(node); + case 122 /* ComputedPropertyName */: return checkComputedPropertyName(node); + case 129 /* Constructor */: return checkConstructor(node); + case 158 /* DeleteExpression */: return checkDeleteExpression(node); + case 150 /* ElementAccessExpression */: return checkElementAccessExpression(node); + case 198 /* ExportAssignment */: return checkExportAssignment(node); + case 199 /* ExternalModuleReference */: return checkExternalModuleReference(node); + case 177 /* ForInStatement */: return checkForInStatement(node); + case 176 /* ForStatement */: return checkForStatement(node); + case 190 /* FunctionDeclaration */: return checkFunctionDeclaration(node); + case 156 /* FunctionExpression */: return checkFunctionExpression(node); + case 130 /* GetAccessor */: return checkGetAccessor(node); + case 202 /* HeritageClause */: return checkHeritageClause(node); + case 134 /* IndexSignature */: return checkIndexSignature(node); + case 192 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); + case 183 /* LabeledStatement */: return checkLabeledStatement(node); + case 204 /* PropertyAssignment */: return checkPropertyAssignment(node); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return checkMethod(node); + case 195 /* ModuleDeclaration */: return checkModuleDeclaration(node); + case 148 /* ObjectLiteralExpression */: return checkObjectLiteralExpression(node); + case 7 /* NumericLiteral */: return checkNumericLiteral(node); + case 124 /* Parameter */: return checkParameter(node); + case 162 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); + case 161 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return checkProperty(node); + case 180 /* ReturnStatement */: return checkReturnStatement(node); + case 131 /* SetAccessor */: return checkSetAccessor(node); + case 207 /* SourceFile */: return checkSourceFile(node); + case 205 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); + case 182 /* SwitchStatement */: return checkSwitchStatement(node); + case 153 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 184 /* ThrowStatement */: return checkThrowStatement(node); + case 141 /* TupleType */: return checkTupleType(node); + case 123 /* TypeParameter */: return checkTypeParameter(node); + case 135 /* TypeReference */: return checkTypeReference(node); + case 189 /* VariableDeclaration */: return checkVariableDeclaration(node); + case 170 /* VariableStatement */: return checkVariableStatement(node); + case 181 /* WithStatement */: return checkWithStatement(node); + case 166 /* YieldExpression */: return checkYieldExpression(node); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var start = ts.skipTrivia(sourceText, node.pos); + function scanToken(pos) { + var start = ts.skipTrivia(sourceText, pos); scanner.setTextPos(start); scanner.scan(); - var end = scanner.getTextPos(); - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, end - start, message, arg0, arg1, arg2)); + return start; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var start = scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + return true; + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); return true; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(node); + var span = ts.getErrorSpanForNode(node); var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos; var length = span.end - start; grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); @@ -5212,27 +5845,27 @@ var ts; } function checkForStatementInAmbientContext(node, kind) { switch (kind) { - case 162 /* Block */: - case 164 /* EmptyStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 184 /* DebuggerStatement */: - case 178 /* LabeledStatement */: - case 165 /* ExpressionStatement */: + case 169 /* Block */: + case 171 /* EmptyStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 188 /* DebuggerStatement */: + case 183 /* LabeledStatement */: + case 172 /* ExpressionStatement */: return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } - function checkAnyParsedSignature(node) { + function checkAnySignatureDeclaration(node) { return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters); } function checkBinaryExpression(node) { @@ -5246,12 +5879,12 @@ var ts; } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: return true; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -5259,11 +5892,11 @@ var ts; function checkLabeledStatement(node) { var current = node.parent; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { break; } - if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) { - return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); + if (current.kind === 183 /* LabeledStatement */ && current.label.text === node.label.text) { + return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceText, node.label)); } current = current.parent; } @@ -5271,21 +5904,21 @@ var ts; function checkBreakOrContinueStatement(node) { var current = node; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 178 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 175 /* SwitchStatement */: - if (node.kind === 172 /* BreakStatement */ && !node.label) { + case 182 /* SwitchStatement */: + if (node.kind === 179 /* BreakStatement */ && !node.label) { return false; } break; @@ -5298,11 +5931,11 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 172 /* 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; + var message = node.kind === 179 /* 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 === 172 /* 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; + var message = node.kind === 179 /* 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); } } @@ -5313,28 +5946,18 @@ var ts; return checkForDisallowedTrailingComma(arguments) || checkForOmittedArgument(arguments); } function checkTypeArguments(typeArguments) { - return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments) || checkForMissingTypeArgument(typeArguments); + return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments); } function checkForOmittedArgument(arguments) { if (arguments) { for (var i = 0, n = arguments.length; i < n; i++) { var arg = arguments[i]; - if (arg.kind === 161 /* OmittedExpression */) { + if (arg.kind === 167 /* OmittedExpression */) { return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkForMissingTypeArgument(typeArguments) { - if (typeArguments) { - for (var i = 0, n = typeArguments.length; i < n; i++) { - var arg = typeArguments[i]; - if (arg.kind === 120 /* Missing */) { - return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Type_expected); - } - } - } - } function checkForAtLeastOneTypeArgument(typeArguments) { if (typeArguments && typeArguments.length === 0) { var start = typeArguments.pos - "<".length; @@ -5349,17 +5972,47 @@ var ts; return grammarErrorAtPos(start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkCatchBlock(node) { + function checkCatchClause(node) { if (node.type) { - var colonStart = ts.skipTrivia(sourceText, node.variable.end); + var colonStart = ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) { - return reportInvalidUseInStrictMode(node.variable); + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } } function checkClassDeclaration(node) { - return checkForDisallowedTrailingComma(node.implementedTypes) || checkForAtLeastOneHeritageClause(node.implementedTypes, "implements"); + return checkClassDeclarationHeritageClauses(node); + } + function checkClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 78 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 101 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + } + } + return false; } function checkForAtLeastOneHeritageClause(types, listType) { if (types && types.length === 0) { @@ -5367,7 +6020,7 @@ var ts; } } function checkConstructor(node) { - return checkAnyParsedSignature(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); + return checkAnySignatureDeclaration(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); } function checkConstructorTypeParameters(node) { if (node.typeParameters) { @@ -5379,6 +6032,11 @@ var ts; return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } } + function checkDeleteExpression(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 64 /* Identifier */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } function checkEnumDeclaration(enumDecl) { var enumIsConst = (enumDecl.flags & 4096 /* Const */) !== 0; var hasError = false; @@ -5386,7 +6044,10 @@ var ts; var inConstantEnumMemberSection = true; for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; - if (inAmbientContext) { + if (node.name.kind === 122 /* ComputedPropertyName */) { + hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { if (node.initializer && !isIntegerLiteral(node.initializer)) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; } @@ -5405,13 +6066,13 @@ var ts; function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 154 /* PrefixOperator */) { + if (expression.kind === 161 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { + if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 6 /* NumericLiteral */) { + if (expression.kind === 7 /* NumericLiteral */) { return isInteger(expression); } return false; @@ -5421,6 +6082,11 @@ var ts; return grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } } + function checkExternalModuleReference(node) { + if (node.expression.kind !== 8 /* StringLiteral */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.String_literal_expected); + } + } function checkForInStatement(node) { return checkVariableDeclarations(node.declarations) || checkForMoreThanOneDeclaration(node.declarations); } @@ -5433,15 +6099,15 @@ var ts; } } function checkFunctionDeclaration(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); } function checkForGenerator(node) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported); + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_currently_supported); } } function checkFunctionExpression(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForGenerator(node); } function checkFunctionName(name) { if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) { @@ -5449,15 +6115,25 @@ var ts; } } function checkGetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } - function checkIndexedAccess(node) { - if (node.index.kind === 120 /* Missing */ && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node) { - var start = ts.skipTrivia(sourceText, node.parent.pos); - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + function checkElementAccessExpression(node) { + if (!node.argumentExpression) { + if (node.parent.kind === 152 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceText, node.expression.end); + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.Expression_expected); + } } } + function checkHeritageClause(node) { + return checkForDisallowedTrailingComma(node.types) || checkForAtLeastOneHeritageClause(node.types, ts.tokenToString(node.token)); + } function checkIndexSignature(node) { return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); } @@ -5476,14 +6152,14 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); } } - else if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + else if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); } else if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); @@ -5491,7 +6167,7 @@ var ts; else if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - else if (parameter.type.kind !== 118 /* StringKeyword */ && parameter.type.kind !== 116 /* NumberKeyword */) { + else if (parameter.type.kind !== 119 /* StringKeyword */ && parameter.type.kind !== 117 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } else if (!node.type) { @@ -5499,13 +6175,52 @@ var ts; } } function checkInterfaceDeclaration(node) { - return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends"); + return checkInterfaceDeclarationHeritageClauses(node); + } + function checkInterfaceDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 78 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 101 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + } + } + return false; } function checkMethod(node) { - return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node); + if (checkAnySignatureDeclaration(node) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node)) { + return true; + } + if (node.parent.kind === 191 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (inAmbientContext) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } + } + else if (node.parent.kind === 192 /* InterfaceDeclaration */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === 139 /* TypeLiteral */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); + } } function checkForBodyInAmbientContext(body, isConstructor) { - if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) { + if (inAmbientContext && body && body.kind === 169 /* Block */) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; return grammarErrorOnFirstToken(body, diagnostic); } @@ -5514,25 +6229,25 @@ var ts; return checkModuleDeclarationName(node) || checkModuleDeclarationStatements(node); } function checkModuleDeclarationName(node) { - if (!inAmbientContext && node.name.kind === 7 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 8 /* StringLiteral */) { return grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } function checkModuleDeclarationStatements(node) { - if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) { + if (node.name.kind === 64 /* Identifier */ && node.body.kind === 196 /* ModuleBlock */) { var statements = node.body.statements; for (var i = 0, n = statements.length; i < n; i++) { var statement = statements[i]; - if (statement.kind === 195 /* ExportAssignment */) { + if (statement.kind === 198 /* ExportAssignment */) { return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) { - return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + else if (ts.isExternalModuleImportDeclaration(statement)) { + return grammarErrorOnNode(ts.getExternalModuleImportDeclarationExpression(statement), ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } } } - function checkObjectLiteral(node) { + function checkObjectLiteralExpression(node) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -5541,26 +6256,22 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; - if (prop.kind === 161 /* OmittedExpression */) { + var name = prop.name; + if (prop.kind === 167 /* OmittedExpression */ || name.kind === 122 /* ComputedPropertyName */) { continue; } - var p = prop; - var name = p.name; var currentKind; - if (p.kind === 143 /* PropertyAssignment */) { + if (prop.kind === 204 /* PropertyAssignment */ || prop.kind === 205 /* ShorthandPropertyAssignment */ || prop.kind === 128 /* MethodDeclaration */) { currentKind = Property; } - else if (p.kind === 144 /* ShorthandPropertyAssignment */) { - currentKind = Property; - } - else if (p.kind === 127 /* GetAccessor */) { + else if (prop.kind === 130 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 128 /* SetAccessor */) { + else if (prop.kind === 131 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + p.kind); + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } if (!ts.hasProperty(seen, name.text)) { seen[name.text] = currentKind; @@ -5598,22 +6309,24 @@ var ts; } function checkModifiers(node) { switch (node.kind) { - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 124 /* Property */: - case 125 /* Method */: - case 131 /* IndexSignature */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 195 /* ExportAssignment */: - case 163 /* VariableStatement */: - case 186 /* FunctionDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 194 /* ImportDeclaration */: - case 123 /* Parameter */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 134 /* IndexSignature */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 195 /* ModuleDeclaration */: + case 194 /* EnumDeclaration */: + case 198 /* ExportAssignment */: + case 170 /* VariableStatement */: + case 190 /* FunctionDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 197 /* ImportDeclaration */: + case 124 /* Parameter */: break; default: return false; @@ -5626,14 +6339,14 @@ var ts; for (var i = 0, n = node.modifiers.length; i < n; i++) { var modifier = node.modifiers[i]; switch (modifier.kind) { - case 106 /* PublicKeyword */: - case 105 /* ProtectedKeyword */: - case 104 /* PrivateKeyword */: + case 107 /* PublicKeyword */: + case 106 /* ProtectedKeyword */: + case 105 /* PrivateKeyword */: var text; - if (modifier.kind === 106 /* PublicKeyword */) { + if (modifier.kind === 107 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 105 /* ProtectedKeyword */) { + else if (modifier.kind === 106 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -5647,50 +6360,50 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 196 /* ModuleBlock */ || node.parent.kind === 207 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= modifierToFlag(modifier.kind); break; - case 107 /* StaticKeyword */: + case 108 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 196 /* ModuleBlock */ || node.parent.kind === 207 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; lastStatic = modifier; break; - case 76 /* ExportKeyword */: + case 77 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 112 /* DeclareKeyword */: + case 113 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) { + else if (inAmbientContext && node.parent.kind === 196 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -5698,7 +6411,7 @@ var ts; break; } } - if (node.kind === 126 /* Constructor */) { + if (node.kind === 129 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -5709,10 +6422,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 197 /* ImportDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 192 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } @@ -5739,20 +6452,20 @@ var ts; var parameterCount = parameters.length; for (var i = 0; i < parameterCount; i++) { var parameter = parameters[i]; - if (parameter.flags & 8 /* Rest */) { + if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); } if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.flags & 4 /* QuestionMark */ || parameter.initializer) { + else if (parameter.questionToken || parameter.initializer) { seenOptionalParameter = true; - if (parameter.flags & 4 /* QuestionMark */ && parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -5763,23 +6476,49 @@ var ts; } } } - function checkPostfixOperator(node) { + function checkPostfixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } } - function checkPrefixOperator(node) { + function checkPrefixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */) { - if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { + if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } - else if (node.operator === 72 /* DeleteKeyword */ && node.operand.kind === 63 /* Identifier */) { - return grammarErrorOnNode(node.operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } } } function checkProperty(node) { - return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node); + if (node.parent.kind === 191 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === 192 /* InterfaceDeclaration */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === 139 /* TypeLiteral */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { + return true; + } + } + return checkForInitializerInAmbientContext(node); + } + function checkComputedPropertyName(node) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_not_currently_supported); + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (node.expression.kind === 163 /* BinaryExpression */ && node.expression.operator === 23 /* CommaToken */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkForDisallowedComputedProperty(node, message) { + if (node.kind === 122 /* ComputedPropertyName */) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node) { if (inAmbientContext && node.initializer) { @@ -5787,12 +6526,11 @@ var ts; } } function checkPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } - function checkForInvalidQuestionMark(node, message) { - if (node.flags & 4 /* QuestionMark */) { - var pos = ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(pos, "?".length, message); + function checkForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); } } function checkReturnStatement(node) { @@ -5801,7 +6539,7 @@ var ts; } } function checkSetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } function checkAccessor(accessor) { var kind = accessor.kind; @@ -5817,10 +6555,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 127 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 130 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 128 /* SetAccessor */) { + else if (kind === 131 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -5829,14 +6567,14 @@ var ts; } else { var parameter = accessor.parameters[0]; - if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); } else if (parameter.initializer) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); @@ -5850,7 +6588,7 @@ var ts; function checkTopLevelElementsForRequiredDeclareModifier(file) { for (var i = 0, n = file.statements.length; i < n; i++) { var decl = file.statements[i]; - if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 170 /* VariableStatement */) { if (checkTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -5858,19 +6596,19 @@ var ts; } } function checkTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { + if (node.kind === 192 /* InterfaceDeclaration */ || node.kind === 197 /* ImportDeclaration */ || node.kind === 198 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); } function checkShorthandPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } function checkSwitchStatement(node) { var firstDefaultClause; for (var i = 0, n = node.clauses.length; i < n; i++) { var clause = node.clauses[i]; - if (clause.kind === 177 /* DefaultClause */) { + if (clause.kind === 201 /* DefaultClause */) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -5887,6 +6625,11 @@ var ts; return grammarErrorOnFirstToken(node.template, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } } + function checkThrowStatement(node) { + if (node.expression === undefined) { + return grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } function checkTupleType(node) { return checkForDisallowedTrailingComma(node.elementTypes) || checkForAtLeastOneType(node); } @@ -5903,13 +6646,29 @@ var ts; function checkTypeReference(node) { return checkTypeArguments(node.typeArguments); } - function checkVariableDeclaration(node) { - if (inAmbientContext && node.initializer) { - var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + function checkBindingElement(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } - if (!inAmbientContext && !node.initializer && isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + function checkVariableDeclaration(node) { + if (inAmbientContext) { + if (ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); + } + if (node.initializer) { + return grammarErrorAtPos(node.initializer.pos - 1, 1, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else { + if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } } if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { return reportInvalidUseInStrictMode(node.name); @@ -5925,10 +6684,10 @@ var ts; } var decl = declarations[0]; if (languageVersion < 2 /* ES6 */) { - if (isLet(decl)) { + if (ts.isLet(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } - else if (isConst(decl)) { + else if (ts.isConst(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } @@ -5939,24 +6698,24 @@ var ts; } function checkForDisallowedLetOrConstStatement(node) { if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node)) { + if (ts.isLet(node)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (isConst(node)) { + else if (ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 181 /* WithStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: return false; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -5982,7 +6741,7 @@ var ts; var commonSourceDirectory; ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(), true); + processRootFile(host.getDefaultLibFilename(options), true); } verifyCompilerOptions(); errors.sort(ts.compareDiagnostics); @@ -6020,7 +6779,7 @@ var ts; } var diagnostic; if (hasExtension(filename)) { - if (!ts.fileExtensionIs(filename, ".ts")) { + if (!options.allowNonTsExtensions && !ts.fileExtensionIs(filename, ".ts")) { diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts; } else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { @@ -6098,8 +6857,8 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchPath = basePath; @@ -6116,10 +6875,10 @@ var ts; } } } - else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 195 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); @@ -6146,9 +6905,9 @@ var ts; } return; } - var firstExternalModule = ts.forEach(files, function (f) { return isExternalModule(f) ? f : undefined; }); + var firstExternalModule = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModule && options.module === 0 /* None */) { - var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator); + var externalModuleErrorSpan = ts.getErrorSpanForNode(firstExternalModule.externalModuleIndicator); var errorStart = ts.skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); var errorLength = externalModuleErrorSpan.end - errorStart; errors.push(ts.createFileDiagnostic(firstExternalModule, errorStart, errorLength, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); @@ -6191,16 +6950,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + else if (node.kind === 197 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 193 /* ModuleBlock */) { + else if (node.kind === 196 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -6216,7 +6975,7 @@ var ts; }); return state; } - else if (node.kind === 192 /* ModuleDeclaration */) { + else if (node.kind === 195 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -6224,6 +6983,10 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + function hasComputedNameButNotSymbol(declaration) { + return declaration.name && declaration.name.kind === 122 /* ComputedPropertyName */; + } + ts.hasComputedNameButNotSymbol = hasComputedNameButNotSymbol; function bindSourceFile(file) { var parent; var container; @@ -6256,21 +7019,22 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 195 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } + ts.Debug.assert(!hasComputedNameButNotSymbol(node)); return node.name.text; } switch (node.kind) { - case 134 /* ConstructorType */: - case 126 /* Constructor */: + case 137 /* ConstructorType */: + case 129 /* Constructor */: return "__constructor"; - case 133 /* FunctionType */: - case 129 /* CallSignature */: + case 136 /* FunctionType */: + case 132 /* CallSignature */: return "__call"; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: return "__new"; - case 131 /* IndexSignature */: + case 134 /* IndexSignature */: return "__index"; } } @@ -6278,6 +7042,9 @@ var ts; return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } function declareSymbol(symbols, parent, node, includes, excludes) { + if (hasComputedNameButNotSymbol(node)) { + return undefined; + } var name = getDeclarationName(node); if (name !== undefined) { var symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); @@ -6298,8 +7065,8 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) { - var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); + if (node.kind === 191 /* ClassDeclaration */ && symbol.exports) { + var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { node.name.parent = node; @@ -6322,15 +7089,15 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var exportKind = 0; if (symbolKind & 107455 /* Value */) { - exportKind |= 4194304 /* ExportValue */; + exportKind |= 1048576 /* ExportValue */; } - if (symbolKind & 3152352 /* Type */) { - exportKind |= 8388608 /* ExportType */; + if (symbolKind & 793056 /* Type */) { + exportKind |= 2097152 /* ExportType */; } if (symbolKind & 1536 /* Namespace */) { - exportKind |= 16777216 /* ExportNamespace */; + exportKind |= 4194304 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 197 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6345,14 +7112,14 @@ var ts; } } function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 1041936 /* HasLocals */) { + if (symbolKind & 255504 /* HasLocals */) { node.locals = {}; } var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolKind & 1048560 /* IsContainer */) { + if (symbolKind & 262128 /* IsContainer */) { container = node; if (lastContainer !== container && !container.nextContainer) { if (lastContainer) { @@ -6371,39 +7138,40 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 136 /* TypeLiteral */: - case 142 /* ObjectLiteral */: - case 189 /* InterfaceDeclaration */: + case 139 /* TypeLiteral */: + case 148 /* ObjectLiteralExpression */: + case 192 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -6418,7 +7186,7 @@ var ts; }); } function bindModuleDeclaration(node) { - if (node.name.kind === 7 /* StringLiteral */) { + if (node.name.kind === 8 /* StringLiteral */) { bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); } else { @@ -6438,14 +7206,13 @@ var ts; } } function bindFunctionOrConstructorType(node) { - var symbolKind = node.kind === 133 /* FunctionType */ ? 131072 /* CallSignature */ : 262144 /* ConstructSignature */; - var symbol = createSymbol(symbolKind, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, false); + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072 /* Signature */); + bindChildren(node, 131072 /* Signature */, false); var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 133 /* FunctionType */ ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 136 /* FunctionType */ ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -6453,7 +7220,7 @@ var ts; bindChildren(node, symbolKind, isBlockScopeContainer); } function bindCatchVariableDeclaration(node) { - var symbol = createSymbol(1 /* FunctionScopedVariable */, node.variable.text || "__missing"); + var symbol = createSymbol(1 /* FunctionScopedVariable */, node.name.text || "__missing"); addDeclarationToSymbol(symbol, node, 1 /* FunctionScopedVariable */); var saveParent = parent; var savedBlockScopeContainer = blockScopeContainer; @@ -6464,10 +7231,10 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; @@ -6480,107 +7247,119 @@ var ts; } bindChildren(node, 2 /* BlockScopedVariable */, false); } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } function bind(node) { node.parent = parent; switch (node.kind) { - case 122 /* TypeParameter */: - bindDeclaration(node, 1048576 /* TypeParameter */, 2103776 /* TypeParameterExcludes */, false); + case 123 /* TypeParameter */: + bindDeclaration(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */, false); break; - case 123 /* Parameter */: - bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); + case 124 /* Parameter */: + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node), false); + } + else { + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); + } break; - case 185 /* VariableDeclaration */: - if (node.flags & 6144 /* BlockScoped */) { + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + if (ts.isBindingPattern(node.name)) { + bindChildren(node, 0, false); + } + else if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } else { bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + bindDeclaration(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0), 107455 /* PropertyExcludes */, false); + break; + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 196 /* EnumMember */: + case 206 /* EnumMember */: bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 129 /* CallSignature */: - bindDeclaration(node, 131072 /* CallSignature */, 0, false); + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + bindDeclaration(node, 131072 /* Signature */, 0, false); break; - case 130 /* ConstructSignature */: - bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + bindDeclaration(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; - case 125 /* Method */: - bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); - break; - case 131 /* IndexSignature */: - bindDeclaration(node, 524288 /* IndexSignature */, 0, false); - break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 126 /* Constructor */: + case 129 /* Constructor */: bindConstructorDeclaration(node); break; - case 127 /* GetAccessor */: + case 130 /* GetAccessor */: bindDeclaration(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 128 /* SetAccessor */: + case 131 /* SetAccessor */: bindDeclaration(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 133 /* FunctionType */: - case 134 /* ConstructorType */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: bindFunctionOrConstructorType(node); break; - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 182 /* CatchBlock */: + case 203 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 188 /* ClassDeclaration */: - bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); + case 191 /* ClassDeclaration */: + bindDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */, false); break; - case 189 /* InterfaceDeclaration */: - bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); + case 192 /* InterfaceDeclaration */: + bindDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */, false); break; - case 190 /* TypeAliasDeclaration */: - bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); + case 193 /* TypeAliasDeclaration */: + bindDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */, false); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: if (ts.isConst(node)) { - bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); + bindDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */, false); } else { - bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); + bindDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */, false); } break; - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 194 /* ImportDeclaration */: - bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); + case 197 /* ImportDeclaration */: + bindDeclaration(node, 8388608 /* Import */, 8388608 /* ImportExcludes */, false); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 175 /* SwitchStatement */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 182 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6766,7 +7545,7 @@ var ts; } function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && member.body) { + if (member.kind === 129 /* Constructor */ && member.body) { return member; } }); @@ -6775,19 +7554,33 @@ var ts; var firstAccessor; var getAccessor; var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 127 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 128 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } + if (accessor.name.kind === 122 /* ComputedPropertyName */) { + firstAccessor = accessor; + if (accessor.kind === 130 /* GetAccessor */) { + getAccessor = accessor; } - }); + else if (accessor.kind === 131 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(node.members, function (member) { + if ((member.kind === 130 /* GetAccessor */ || member.kind === 131 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 130 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 131 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + } return { firstAccessor: firstAccessor, getAccessor: getAccessor, @@ -6889,14 +7682,14 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } - function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) { + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); if (type) { emitType(type); } else { - resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -6934,37 +7727,37 @@ var ts; emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); } } - function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) { + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; emitType(type); } function emitType(type) { switch (type.kind) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 7 /* StringLiteral */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: + case 98 /* VoidKeyword */: + case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return emitTypeReference(type); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return emitTypeQuery(type); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return emitArrayType(type); - case 138 /* TupleType */: + case 141 /* TupleType */: return emitTupleType(type); - case 139 /* UnionType */: + case 142 /* UnionType */: return emitUnionType(type); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return emitParenType(type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: return emitTypeLiteral(type); - case 63 /* Identifier */: + case 64 /* Identifier */: return emitEntityName(type); case 121 /* QualifiedName */: return emitEntityName(type); @@ -6972,11 +7765,11 @@ var ts; ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 197 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 63 /* Identifier */) { + if (entityName.kind === 64 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -7043,7 +7836,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 189 /* InterfaceDeclaration */) { + if (node.kind !== 192 /* InterfaceDeclaration */) { write("declare "); } } @@ -7079,13 +7872,13 @@ var ts; write("import "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - if (node.entityName) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError); + if (ts.isInternalModuleImportDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); write(";"); } else { write("require("); - writeTextOfNode(currentSourceFile, node.externalModuleName); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportDeclarationExpression(node)); write(");"); } writer.writeLine(); @@ -7103,7 +7896,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 193 /* ModuleBlock */) { + while (node.body.kind !== 196 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -7127,7 +7920,7 @@ var ts; write("type "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); } @@ -7168,49 +7961,53 @@ var ts; write(","); writeLine(); } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 128 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { increaseIndent(); emitJsDocComments(node); decreaseIndent(); writeTextOfNode(currentSourceFile, node.name); - if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 136 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 125 /* Method */ || node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.kind === 129 /* CallSignature */ || node.parent.kind === 130 /* ConstructSignature */); + if (node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 139 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 128 /* MethodDeclaration */ || node.parent.kind === 127 /* MethodSignature */ || node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || node.parent.kind === 132 /* CallSignature */ || node.parent.kind === 133 /* ConstructSignature */); emitType(node.constraint); } else { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 191 /* 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 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7235,10 +8032,10 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 188 /* ClassDeclaration */) { + if (node.parent.parent.kind === 191 /* ClassDeclaration */) { 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; } else { @@ -7247,7 +8044,7 @@ var ts; return { diagnosticMessage: diagnosticMessage, errorNode: node, - typeName: node.parent.name + typeName: node.parent.parent.name }; } } @@ -7270,10 +8067,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } - emitHeritageClause(node.implementedTypes, true); + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); write(" {"); writeLine(); increaseIndent(); @@ -7294,7 +8092,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); write(" {"); writeLine(); increaseIndent(); @@ -7313,28 +8111,28 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 189 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { writeTextOfNode(currentSourceFile, node.name); - if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if ((node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) { + if ((node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) && node.parent.kind === 139 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 185 /* VariableDeclaration */) { + if (node.kind === 189 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 124 /* Property */) { + else if (node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -7384,25 +8182,25 @@ var ts; var accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 127 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 130 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; } } - writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); } write(";"); writeLine(); } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 127 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type; + return accessor.kind === 130 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type; } } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 128 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 131 /* SetAccessor */) { if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -7431,24 +8229,24 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 190 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 190 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 125 /* Method */) { + else if (node.kind === 128 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 190 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 126 /* Constructor */) { + else if (node.kind === 129 /* Constructor */) { write("constructor"); } else { writeTextOfNode(currentSourceFile, node.name); - if (node.flags & 4 /* QuestionMark */) { + if (ts.hasQuestionToken(node)) { write("?"); } } @@ -7460,11 +8258,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 130 /* ConstructSignature */ || node.kind === 134 /* ConstructorType */) { + if (node.kind === 133 /* ConstructSignature */ || node.kind === 137 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 131 /* IndexSignature */) { + if (node.kind === 134 /* IndexSignature */) { write("["); } else { @@ -7473,20 +8271,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 131 /* IndexSignature */) { + if (node.kind === 134 /* IndexSignature */) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 133 /* FunctionType */ || node.kind === 134 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 136 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 136 /* FunctionType */ || node.kind === 137 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 139 /* TypeLiteral */) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 129 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -7497,27 +8295,28 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 131 /* IndexSignature */: + case 134 /* IndexSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: @@ -7532,44 +8331,50 @@ var ts; function emitParameterDeclaration(node) { increaseIndent(); emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { + if (node.dotDotDotToken) { write("..."); } - writeTextOfNode(currentSourceFile, node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + if (ts.isBindingPattern(node.name)) { + write("_" + ts.indexOf(node.parent.parameters, node)); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (node.initializer || ts.hasQuestionToken(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.parent.kind === 136 /* TypeLiteral */) { + if (node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || node.parent.parent.kind === 139 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 126 /* Constructor */: + case 129 /* Constructor */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7584,38 +8389,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: + case 129 /* Constructor */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: return emitFunctionDeclaration(node); - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: + case 133 /* ConstructSignature */: + case 132 /* CallSignature */: + case 134 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return emitAccessorDeclaration(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return emitVariableStatement(node); - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return emitPropertyDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return emitClassDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 193 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 196 /* EnumMember */: + case 206 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return emitImportDeclaration(node); - case 195 /* ExportAssignment */: + case 198 /* ExportAssignment */: return emitExportAssignment(node); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return emitSourceFile(node); } } @@ -7687,6 +8494,9 @@ var ts; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; var extendsEmitted = false; + var tempCount = 0; + var tempVariables; + var tempParameters; var writeEmittedFiles = writeJavaScriptFile; var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; @@ -7842,7 +8652,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) { + else if (node.kind === 190 /* FunctionDeclaration */ || node.kind === 156 /* FunctionExpression */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 130 /* GetAccessor */ || node.kind === 131 /* SetAccessor */ || node.kind === 195 /* ModuleDeclaration */ || node.kind === 191 /* ClassDeclaration */ || node.kind === 194 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -7924,7 +8734,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 197 /* SourceFile */) { + if (node.kind != 207 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -7947,6 +8757,38 @@ var ts; function writeJavaScriptFile(emitOutput, writeByteOrderMark) { writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } + function createTempVariable(location, forLoopVariable) { + var name = forLoopVariable ? "_i" : undefined; + while (true) { + if (name && resolver.isUnknownIdentifier(location, name)) { + break; + } + name = "_" + (tempCount < 25 ? String.fromCharCode(tempCount + (tempCount < 8 ? 0 : 1) + 97 /* a */) : tempCount - 25); + tempCount++; + } + var result = ts.createNode(64 /* Identifier */); + result.text = name; + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } function emitTokenText(tokenKind, startPos, emitFn) { var tokenString = ts.tokenToString(tokenKind); if (emitFn) { @@ -7963,15 +8805,12 @@ var ts; emit(node); } } - function emitTrailingCommaIfPresent(nodeList, isMultiline) { + function emitTrailingCommaIfPresent(nodeList) { if (nodeList.hasTrailingComma) { write(","); - if (isMultiline) { - writeLine(); - } } } - function emitCommaList(nodes, includeTrailingComma, count) { + function emitCommaList(nodes, count) { if (!(count >= 0)) { count = nodes.length; } @@ -7982,12 +8821,9 @@ var ts; } emit(nodes[i]); } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, false); - } } } - function emitMultiLineList(nodes, includeTrailingComma) { + function emitMultiLineList(nodes) { if (nodes) { for (var i = 0; i < nodes.length; i++) { if (i) { @@ -7996,9 +8832,6 @@ var ts; writeLine(); emit(nodes[i]); } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, true); - } } } function emitLines(nodes) { @@ -8010,20 +8843,26 @@ var ts; emit(nodes[i]); } } + function isBinaryOrOctalIntegerLiteral(text) { + if (text.length <= 0) { + return false; + } + if (text.charCodeAt(1) === 66 /* B */ || text.charCodeAt(1) === 98 /* b */ || text.charCodeAt(1) === 79 /* O */ || text.charCodeAt(1) === 111 /* o */) { + return true; + } + return false; + } function emitLiteral(node) { - var text = getLiteralText(); - if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + var text = compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; + if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } + else if (compilerOptions.target < 2 /* ES6 */ && node.kind === 7 /* NumericLiteral */ && isBinaryOrOctalIntegerLiteral(text)) { + write(node.text); + } else { write(text); } - function getLiteralText() { - if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) { - return getTemplateLiteralAsStringLiteral(node); - } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } } function getTemplateLiteralAsStringLiteral(node) { return '"' + ts.escapeString(node.text) + '"'; @@ -8033,14 +8872,14 @@ var ts; ts.forEachChild(node, emit); return; } - ts.Debug.assert(node.parent.kind !== 149 /* TaggedTemplateExpression */); + ts.Debug.assert(node.parent.kind !== 153 /* TaggedTemplateExpression */); var emitOuterParens = ts.isExpression(node.parent) && templateNeedsParens(node, node.parent); if (emitOuterParens) { write("("); } emitLiteral(node.head); ts.forEach(node.templateSpans, function (templateSpan) { - var needsParens = templateSpan.expression.kind !== 151 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + var needsParens = templateSpan.expression.kind !== 155 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; write(" + "); if (needsParens) { write("("); @@ -8059,12 +8898,12 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.func === template; - case 151 /* ParenExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return parent.expression === template; + case 155 /* ParenthesizedExpression */: return false; - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: ts.Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -8073,18 +8912,18 @@ var ts; function comparePrecedenceToBinaryPlus(expression) { ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); switch (expression.kind) { - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: switch (expression.operator) { - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: return 1 /* GreaterThan */; - case 32 /* PlusToken */: + case 33 /* PlusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -8096,12 +8935,15 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - if (node.kind === 7 /* StringLiteral */) { + if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } + else if (node.kind === 122 /* ComputedPropertyName */) { + emit(node.expression); + } else { write("\""); - if (node.kind === 6 /* NumericLiteral */) { + if (node.kind === 7 /* NumericLiteral */) { write(node.text); } else { @@ -8113,31 +8955,34 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 190 /* FunctionDeclaration */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return parent.name === node; - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 195 /* ExportAssignment */: + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 198 /* ExportAssignment */: return false; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return node.parent.label === node; - case 182 /* CatchBlock */: - return node.parent.variable === node; + case 203 /* CatchClause */: + return node.parent.name === node; } } function emitExpressionIdentifier(node) { @@ -8149,7 +8994,10 @@ var ts; writeTextOfNode(currentSourceFile, node); } function emitIdentifier(node) { - if (!isNotExpressionIdentifier(node)) { + if (!node.parent) { + write(node.text); + } + else if (!isNotExpressionIdentifier(node)) { emitExpressionIdentifier(node); } else { @@ -8176,18 +9024,32 @@ var ts; write("super"); } } + function emitObjectBindingPattern(node) { + write("{ "); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); + write("]"); + } function emitArrayLiteral(node) { if (node.flags & 256 /* MultiLine */) { write("["); increaseIndent(); - emitMultiLineList(node.elements, true); + emitMultiLineList(node.elements); + emitTrailingCommaIfPresent(node.elements); decreaseIndent(); writeLine(); write("]"); } else { write("["); - emitCommaList(node.elements, true); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); write("]"); } } @@ -8198,17 +9060,40 @@ var ts; else if (node.flags & 256 /* MultiLine */) { write("{"); increaseIndent(); - emitMultiLineList(node.properties, compilerOptions.target >= 1 /* ES5 */); + emitMultiLineList(node.properties); + if (compilerOptions.target >= 1 /* ES5 */) { + emitTrailingCommaIfPresent(node.properties); + } decreaseIndent(); writeLine(); write("}"); } else { write("{ "); - emitCommaList(node.properties, compilerOptions.target >= 1 /* ES5 */); + emitCommaList(node.properties); + if (compilerOptions.target >= 1 /* ES5 */) { + emitTrailingCommaIfPresent(node.properties); + } write(" }"); } } + function emitComputedPropertyName(node) { + write("["); + emit(node.expression); + write("]"); + } + function emitMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + if (compilerOptions.target < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + emitTrailingComments(node); + } function emitPropertyAssignment(node) { emitLeadingComments(node); emit(node.name); @@ -8216,33 +9101,19 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitShortHandPropertyAssignment(node) { - function emitAsNormalPropertyAssignment() { - emitLeadingComments(node); - emit(node.name); + function emitShorthandPropertyAssignment(node) { + emitLeadingComments(node); + emit(node.name); + if (compilerOptions.target < 2 /* ES6 */ || resolver.getExpressionNamePrefix(node.name)) { write(": "); emitExpressionIdentifier(node.name); - emitTrailingComments(node); - } - if (compilerOptions.target < 2 /* ES6 */) { - emitAsNormalPropertyAssignment(); - } - else if (compilerOptions.target >= 2 /* ES6 */) { - var prefix = resolver.getExpressionNamePrefix(node.name); - if (prefix) { - emitAsNormalPropertyAssignment(); - } - else { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } } + emitTrailingComments(node); } function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === 145 /* PropertyAccess */ ? ts.declarationNameToString(node.right) : ts.getTextOfNode(node.index); + var propertyName = node.kind === 149 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } @@ -8252,6 +9123,11 @@ var ts; if (tryEmitConstantValue(node)) { return; } + emit(node.expression); + write("."); + emit(node.name); + } + function emitQualifiedName(node) { emit(node.left); write("."); emit(node.right); @@ -8260,42 +9136,42 @@ var ts; if (tryEmitConstantValue(node)) { return; } - emit(node.object); + emit(node.expression); write("["); - emit(node.index); + emit(node.argumentExpression); write("]"); } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 90 /* SuperKeyword */) { write("_super"); superCall = true; } else { - emit(node.func); - superCall = node.func.kind === 145 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; + emit(node.expression); + superCall = node.expression.kind === 149 /* PropertyAccessExpression */ && node.expression.expression.kind === 90 /* SuperKeyword */; } if (superCall) { write(".call("); - emitThis(node.func); + emitThis(node.expression); if (node.arguments.length) { write(", "); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); } write(")"); } else { write("("); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); write(")"); } } function emitNewExpression(node) { write("new "); - emit(node.func); + emit(node.expression); if (node.arguments) { write("("); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); write(")"); } } @@ -8306,12 +9182,12 @@ var ts; emit(node.template); } function emitParenExpression(node) { - if (node.expression.kind === 150 /* TypeAssertion */) { - var operand = node.expression.operand; - while (operand.kind == 150 /* TypeAssertion */) { - operand = operand.operand; + if (node.expression.kind === 154 /* TypeAssertionExpression */) { + var operand = node.expression.expression; + while (operand.kind == 154 /* TypeAssertionExpression */) { + operand = operand.expression; } - if (operand.kind !== 154 /* PrefixOperator */ && operand.kind !== 155 /* PostfixOperator */ && operand.kind !== 148 /* NewExpression */ && !(operand.kind === 147 /* CallExpression */ && node.parent.kind === 148 /* NewExpression */) && !(operand.kind === 152 /* FunctionExpression */ && node.parent.kind === 147 /* CallExpression */)) { + if (operand.kind !== 161 /* PrefixUnaryExpression */ && operand.kind !== 160 /* VoidExpression */ && operand.kind !== 159 /* TypeOfExpression */ && operand.kind !== 158 /* DeleteExpression */ && operand.kind !== 162 /* PostfixUnaryExpression */ && operand.kind !== 152 /* NewExpression */ && !(operand.kind === 151 /* CallExpression */ && node.parent.kind === 152 /* NewExpression */) && !(operand.kind === 156 /* FunctionExpression */ && node.parent.kind === 151 /* CallExpression */)) { emit(operand); return; } @@ -8320,34 +9196,50 @@ var ts; emit(node.expression); write(")"); } - function emitUnaryExpression(node) { - if (node.kind === 154 /* PrefixOperator */) { - write(ts.tokenToString(node.operator)); - } - if (node.operator >= 63 /* Identifier */) { - write(" "); - } - else if (node.kind === 154 /* PrefixOperator */ && node.operand.kind === 154 /* PrefixOperator */) { + function emitDeleteExpression(node) { + write(ts.tokenToString(73 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(98 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(96 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function emitPrefixUnaryExpression(node) { + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 161 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { + if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 33 /* MinusToken */ && (operand.operator === 33 /* MinusToken */ || operand.operator === 38 /* MinusMinusToken */)) { + else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { write(" "); } } emit(node.operand); - if (node.kind === 155 /* PostfixOperator */) { - write(ts.tokenToString(node.operator)); - } + } + function emitPostfixUnaryExpression(node) { + emit(node.operand); + write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - emit(node.left); - if (node.operator !== 22 /* CommaToken */) + if (node.operator === 52 /* EqualsToken */ && (node.left.kind === 148 /* ObjectLiteralExpression */ || node.left.kind === 147 /* ArrayLiteralExpression */)) { + emitDestructuring(node); + } + else { + emit(node.left); + if (node.operator !== 23 /* CommaToken */) + write(" "); + write(ts.tokenToString(node.operator)); write(" "); - write(ts.tokenToString(node.operator)); - write(" "); - emit(node.right); + emit(node.right); + } } function emitConditionalExpression(node) { emit(node.condition); @@ -8357,21 +9249,24 @@ var ts; emit(node.whenFalse); } function emitBlock(node) { - emitToken(13 /* OpenBraceToken */, node.pos); + emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 193 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */); + if (node.kind === 196 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 195 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); + if (node.kind === 196 /* ModuleBlock */) { + emitTempDeclarations(true); + } decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.statements.end); + emitToken(15 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 162 /* Block */) { + if (node.kind === 169 /* Block */) { write(" "); emit(node); } @@ -8383,7 +9278,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 153 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 157 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -8395,16 +9290,16 @@ var ts; } function emitIfStatement(node) { emitLeadingComments(node); - var endPos = emitToken(82 /* IfKeyword */, node.pos); + var endPos = emitToken(83 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); + emitToken(17 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(74 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 166 /* IfStatement */) { + emitToken(75 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 173 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -8417,7 +9312,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 162 /* Block */) { + if (node.statement.kind === 169 /* Block */) { write(" "); } else { @@ -8434,21 +9329,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); + var endPos = emitToken(81 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations[0] && ts.isLet(node.declarations[0])) { - emitToken(102 /* LetKeyword */, endPos); + emitToken(103 /* LetKeyword */, endPos); } else if (node.declarations[0] && ts.isConst(node.declarations[0])) { - emitToken(68 /* ConstKeyword */, endPos); + emitToken(69 /* ConstKeyword */, endPos); } else { - emitToken(96 /* VarKeyword */, endPos); + emitToken(97 /* VarKeyword */, endPos); } write(" "); - emitCommaList(node.declarations, false); + emitCommaList(node.declarations); } if (node.initializer) { emit(node.initializer); @@ -8461,17 +9356,17 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); + var endPos = emitToken(81 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; if (ts.isLet(decl)) { - emitToken(102 /* LetKeyword */, endPos); + emitToken(103 /* LetKeyword */, endPos); } else { - emitToken(96 /* VarKeyword */, endPos); + emitToken(97 /* VarKeyword */, endPos); } write(" "); emit(decl); @@ -8482,17 +9377,17 @@ var ts; } write(" in "); emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); + emitToken(17 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 179 /* BreakStatement */ ? 65 /* BreakKeyword */ : 70 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { emitLeadingComments(node); - emitToken(88 /* ReturnKeyword */, node.pos); + emitToken(89 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); emitTrailingComments(node); @@ -8504,24 +9399,24 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(90 /* SwitchKeyword */, node.pos); + var endPos = emitToken(91 /* SwitchKeyword */, node.pos); write(" "); - emitToken(15 /* OpenParenToken */, endPos); + emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(16 /* CloseParenToken */, node.expression.end); + endPos = emitToken(17 /* CloseParenToken */, node.expression.end); write(" "); - emitToken(13 /* OpenBraceToken */, endPos); + emitToken(14 /* OpenBraceToken */, endPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.clauses.end); + emitToken(15 /* CloseBraceToken */, node.clauses.end); } function isOnSameLine(node1, node2) { return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 176 /* CaseClause */) { + if (node.kind === 200 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -8547,25 +9442,25 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchBlock); + emit(node.catchClause); if (node.finallyBlock) { writeLine(); write("finally "); emit(node.finallyBlock); } } - function emitCatchBlock(node) { + function emitCatchClause(node) { writeLine(); - var endPos = emitToken(66 /* CatchKeyword */, node.pos); + var endPos = emitToken(67 /* CatchKeyword */, node.pos); write(" "); - emitToken(15 /* OpenParenToken */, endPos); - emit(node.variable); - emitToken(16 /* CloseParenToken */, node.variable.end); + emitToken(16 /* OpenParenToken */, endPos); + emit(node.name); + emitToken(17 /* CloseParenToken */, node.name.end); write(" "); - emitBlock(node); + emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(70 /* DebuggerKeyword */, node.pos); + emitToken(71 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -8576,7 +9471,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 192 /* ModuleDeclaration */); + } while (node && node.kind !== 195 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -8589,10 +9484,183 @@ var ts; emitNode(node.name); emitEnd(node.name); } + function emitDestructuring(root, value) { + var emitCount = 0; + var isDeclaration = (root.kind === 189 /* VariableDeclaration */ && !(root.flags & 1 /* Export */)) || root.kind === 124 /* Parameter */; + if (root.kind === 163 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + emitBindingElement(root, value); + } + function emitAssignment(name, value) { + if (emitCount++) { + write(", "); + } + if (name.parent && (name.parent.kind === 189 /* VariableDeclaration */ || name.parent.kind === 146 /* BindingElement */)) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + } + function ensureIdentifier(expr) { + if (expr.kind !== 64 /* Identifier */) { + var identifier = createTempVariable(root); + if (!isDeclaration) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + expr = identifier; + } + return expr; + } + function createVoidZero() { + var zero = ts.createNode(7 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createNode(160 /* VoidExpression */); + result.expression = zero; + return result; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value); + var equals = ts.createNode(163 /* BinaryExpression */); + equals.left = value; + equals.operator = 30 /* EqualsEqualsEqualsToken */; + equals.right = createVoidZero(); + var cond = ts.createNode(164 /* ConditionalExpression */); + cond.condition = equals; + cond.whenTrue = defaultValue; + cond.whenFalse = value; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createNode(7 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function parenthesizeForAccess(expr) { + if (expr.kind === 64 /* Identifier */ || expr.kind === 149 /* PropertyAccessExpression */ || expr.kind === 150 /* ElementAccessExpression */) { + return expr; + } + var node = ts.createNode(155 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function createPropertyAccess(object, propName) { + if (propName.kind !== 64 /* Identifier */) { + return createElementAccess(object, propName); + } + var node = ts.createNode(149 /* PropertyAccessExpression */); + node.expression = parenthesizeForAccess(object); + node.name = propName; + return node; + } + function createElementAccess(object, index) { + var node = ts.createNode(150 /* ElementAccessExpression */); + node.expression = parenthesizeForAccess(object); + node.argumentExpression = index; + return node; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 204 /* PropertyAssignment */ || p.kind === 205 /* ShorthandPropertyAssignment */) { + var propName = (p.name); + emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 167 /* OmittedExpression */) { + emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 163 /* BinaryExpression */ && target.operator === 52 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 148 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 147 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value); + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (root.parent.kind === 172 /* ExpressionStatement */) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 155 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 155 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + if (pattern.kind === 144 /* ObjectBindingPattern */) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccess(value, propName)); + } + else if (element.kind !== 167 /* OmittedExpression */) { + emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); + } + } + } + else { + emitAssignment(target.name, value); + } + } + } function emitVariableDeclaration(node) { emitLeadingComments(node); - emitModuleMemberName(node); - emitOptional(" = ", node.initializer); + if (ts.isBindingPattern(node.name)) { + emitDestructuring(node); + } + else { + emitModuleMemberName(node); + emitOptional(" = ", node.initializer); + } emitTrailingComments(node); } function emitVariableStatement(node) { @@ -8608,30 +9676,48 @@ var ts; write("var "); } } - emitCommaList(node.declarations, false); + emitCommaList(node.declarations); write(";"); emitTrailingComments(node); } function emitParameter(node) { emitLeadingComments(node); - emit(node.name); + if (ts.isBindingPattern(node.name)) { + var name = createTempVariable(node); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name); + emit(name); + } + else { + emit(node.name); + } emitTrailingComments(node); } function emitDefaultValueAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.initializer) { + var tempIndex = 0; + ts.forEach(node.parameters, function (p) { + if (ts.isBindingPattern(p.name)) { writeLine(); - emitStart(param); + write("var "); + emitDestructuring(p, tempParameters[tempIndex]); + write(";"); + tempIndex++; + } + else if (p.initializer) { + writeLine(); + emitStart(p); write("if ("); - emitNode(param.name); + emitNode(p.name); write(" === void 0)"); - emitEnd(param); + emitEnd(p); write(" { "); - emitStart(param); - emitNode(param.name); + emitStart(p); + emitNode(p.name); write(" = "); - emitNode(param.initializer); - emitEnd(param); + emitNode(p.initializer); + emitEnd(p); write("; }"); } }); @@ -8640,6 +9726,7 @@ var ts; if (ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; + var tempName = createTempVariable(node, true).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -8651,22 +9738,22 @@ var ts; writeLine(); write("for ("); emitStart(restParam); - write("var _i = " + restIndex + ";"); + write("var " + tempName + " = " + restIndex + ";"); emitEnd(restParam); write(" "); emitStart(restParam); - write("_i < arguments.length;"); + write(tempName + " < arguments.length;"); emitEnd(restParam); write(" "); emitStart(restParam); - write("_i++"); + write(tempName + "++"); emitEnd(restParam); write(") {"); increaseIndent(); writeLine(); emitStart(restParam); emitNode(restParam.name); - write("[_i - " + restIndex + "] = arguments[_i];"); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); writeLine(); @@ -8675,7 +9762,7 @@ var ts; } function emitAccessor(node) { emitLeadingComments(node); - write(node.kind === 127 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 130 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); emitTrailingComments(node); @@ -8684,15 +9771,15 @@ var ts; if (!node.body) { return emitPinnedOrTripleSlashComments(node); } - if (node.kind !== 125 /* Method */) { + if (node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { emitLeadingComments(node); } write("function "); - if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) { + if (node.kind === 190 /* FunctionDeclaration */ || (node.kind === 156 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); - if (node.kind !== 125 /* Method */) { + if (node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { emitTrailingComments(node); } } @@ -8708,39 +9795,47 @@ var ts; increaseIndent(); write("("); if (node) { - emitCommaList(node.parameters, false, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); + emitCommaList(node.parameters, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); } write(")"); decreaseIndent(); } function emitSignatureAndBody(node) { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; emitSignatureParameters(node); write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 169 /* Block */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 169 /* Block */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); write("return "); emitNode(node.body); emitEnd(node.body); - write("; "); + write(";"); + emitTempDeclarations(false); + write(" "); emitStart(node.body); write("}"); emitEnd(node.body); } else { - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -8751,11 +9846,12 @@ var ts; write(";"); emitTrailingComments(node.body); } + emitTempDeclarations(true); writeLine(); - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); - emitToken(14 /* CloseBraceToken */, node.body.statements.end); + emitToken(15 /* CloseBraceToken */, node.body.statements.end); } else { decreaseIndent(); @@ -8774,15 +9870,18 @@ var ts; emitEnd(node); write(";"); } + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 165 /* ExpressionStatement */) { + if (statement && statement.kind === 172 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 147 /* CallExpression */) { - var func = expr.func; - if (func && func.kind === 89 /* SuperKeyword */) { + if (expr && expr.kind === 151 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 90 /* SuperKeyword */) { return statement; } } @@ -8805,12 +9904,15 @@ var ts; } }); } - function emitMemberAccess(memberName) { - if (memberName.kind === 7 /* StringLiteral */ || memberName.kind === 6 /* NumericLiteral */) { + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { write("["); emitNode(memberName); write("]"); } + else if (memberName.kind === 122 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } else { write("."); emitNode(memberName); @@ -8818,7 +9920,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 124 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { + if (member.kind === 126 /* PropertyDeclaration */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -8829,7 +9931,7 @@ var ts; else { write("this"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emit(member.initializer); @@ -8841,7 +9943,7 @@ var ts; } function emitMemberFunctions(node) { ts.forEach(node.members, function (member) { - if (member.kind === 125 /* Method */) { + if (member.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */) { if (!member.body) { return emitPinnedOrTripleSlashComments(member); } @@ -8853,7 +9955,7 @@ var ts; if (!(member.flags & 128 /* Static */)) { write(".prototype"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emitStart(member); @@ -8863,7 +9965,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) { + else if (member.kind === 130 /* GetAccessor */ || member.kind === 131 /* SetAccessor */) { var accessors = getAllAccessorDeclarations(node, member); if (member === accessors.firstAccessor) { writeLine(); @@ -8918,19 +10020,20 @@ var ts; write("var "); emit(node.name); write(" = (function ("); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { write("_super"); } write(") {"); increaseIndent(); scopeEmitStart(node); - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("__extends("); emit(node.name); write(", _super);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } writeLine(); emitConstructorOfClass(); @@ -8941,16 +10044,16 @@ var ts; write("return "); emitNode(node.name); } - emitToken(14 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); + emitToken(15 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); write(";"); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); + emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); - if (node.baseType) { - emit(node.baseType.typeName); + if (baseTypeNode) { + emit(baseTypeNode.typeName); } write(");"); emitEnd(node); @@ -8965,8 +10068,14 @@ var ts; } emitTrailingComments(node); function emitConstructorOfClass() { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && !member.body) { + if (member.kind === 129 /* Constructor */ && !member.body) { emitPinnedOrTripleSlashComments(member); } }); @@ -8988,7 +10097,7 @@ var ts; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); - if (node.baseType) { + if (baseTypeNode) { var superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); @@ -8998,11 +10107,11 @@ var ts; emitParameterPropertyAssignments(ctor); } else { - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("_super.apply(this, arguments);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } } emitMemberAssignments(node, 0); @@ -9012,17 +10121,21 @@ var ts; statements = statements.slice(1); emitLines(statements); } + emitTempDeclarations(true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(14 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { emitTrailingComments(ctor); } + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; } } function emitInterfaceDeclaration(node) { @@ -9053,7 +10166,7 @@ var ts; emitEnumMemberDeclarations(isConstEnum); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); + emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -9098,7 +10211,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 195 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -9121,8 +10234,14 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 193 /* ModuleBlock */) { + if (node.body.kind === 196 /* ModuleBlock */) { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + tempCount = 0; + tempVariables = undefined; emit(node.body); + tempCount = saveTempCount; + tempVariables = saveTempVariables; } else { write("{"); @@ -9134,7 +10253,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(14 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -9155,7 +10274,7 @@ var ts; emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (ts.isExternalModuleImportDeclaration(node) && node.parent.kind === 207 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -9176,15 +10295,16 @@ var ts; write("var "); emitModuleMemberName(node); write(" = "); - if (node.entityName) { - emit(node.entityName); + if (ts.isInternalModuleImportDeclaration(node)) { + emit(node.moduleReference); } else { + var literal = ts.getExternalModuleImportDeclarationExpression(node); write("require("); - emitStart(node.externalModuleName); - emitLiteral(node.externalModuleName); - emitEnd(node.externalModuleName); - emitToken(16 /* CloseParenToken */, node.externalModuleName.end); + emitStart(literal); + emitLiteral(literal); + emitEnd(literal); + emitToken(17 /* CloseParenToken */, literal.end); } write(";"); emitEnd(node); @@ -9194,16 +10314,16 @@ var ts; } function getExternalImportDeclarations(node) { var result = []; - ts.forEach(node.statements, function (stat) { - if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { - result.push(stat); + ts.forEach(node.statements, function (statement) { + if (ts.isExternalModuleImportDeclaration(statement) && resolver.isReferencedImportDeclaration(statement)) { + result.push(statement); } }); return result; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 198 /* ExportAssignment */) { return node; } }); @@ -9218,7 +10338,7 @@ var ts; write("[\"require\", \"exports\""); ts.forEach(imports, function (imp) { write(", "); - emitLiteral(imp.externalModuleName); + emitLiteral(ts.getExternalModuleImportDeclarationExpression(imp)); }); ts.forEach(node.amdDependencies, function (amdDependency) { var text = "\"" + amdDependency + "\""; @@ -9314,6 +10434,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); } + emitLeadingComments(node.endOfFileToken); } function emitNode(node) { if (!node) { @@ -9323,129 +10444,144 @@ var ts; return emitPinnedOrTripleSlashComments(node); } switch (node.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: return emitIdentifier(node); - case 123 /* Parameter */: + case 124 /* Parameter */: return emitParameter(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return emitMethod(node); + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return emitAccessor(node); - case 91 /* ThisKeyword */: + case 92 /* ThisKeyword */: return emitThis(node); - case 89 /* SuperKeyword */: + case 90 /* SuperKeyword */: return emitSuper(node); - case 87 /* NullKeyword */: + case 88 /* NullKeyword */: return write("null"); - case 93 /* TrueKeyword */: + case 94 /* TrueKeyword */: return write("true"); - case 78 /* FalseKeyword */: + case 79 /* FalseKeyword */: return write("false"); - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 8 /* RegularExpressionLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 11 /* TemplateMiddle */: - case 12 /* TemplateTail */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 9 /* RegularExpressionLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 11 /* TemplateHead */: + case 12 /* TemplateMiddle */: + case 13 /* TemplateTail */: return emitLiteral(node); - case 158 /* TemplateExpression */: + case 165 /* TemplateExpression */: return emitTemplateExpression(node); - case 159 /* TemplateSpan */: + case 168 /* TemplateSpan */: return emitTemplateSpan(node); case 121 /* QualifiedName */: - return emitPropertyAccess(node); - case 141 /* ArrayLiteral */: + return emitQualifiedName(node); + case 144 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 145 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 147 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 143 /* PropertyAssignment */: + case 204 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 144 /* ShorthandPropertyAssignment */: - return emitShortHandPropertyAssignment(node); - case 145 /* PropertyAccess */: + case 205 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 122 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 149 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 146 /* IndexedAccess */: + case 150 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 147 /* CallExpression */: + case 151 /* CallExpression */: return emitCallExpression(node); - case 148 /* NewExpression */: + case 152 /* NewExpression */: return emitNewExpression(node); - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: - return emit(node.operand); - case 151 /* ParenExpression */: + case 154 /* TypeAssertionExpression */: + return emit(node.expression); + case 155 /* ParenthesizedExpression */: return emitParenExpression(node); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return emitUnaryExpression(node); - case 156 /* BinaryExpression */: + case 158 /* DeleteExpression */: + return emitDeleteExpression(node); + case 159 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 160 /* VoidExpression */: + return emitVoidExpression(node); + case 161 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 162 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 163 /* BinaryExpression */: return emitBinaryExpression(node); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return emitConditionalExpression(node); - case 161 /* OmittedExpression */: + case 167 /* OmittedExpression */: return; - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return emitBlock(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return emitVariableStatement(node); - case 164 /* EmptyStatement */: + case 171 /* EmptyStatement */: return write(";"); - case 165 /* ExpressionStatement */: + case 172 /* ExpressionStatement */: return emitExpressionStatement(node); - case 166 /* IfStatement */: + case 173 /* IfStatement */: return emitIfStatement(node); - case 167 /* DoStatement */: + case 174 /* DoStatement */: return emitDoStatement(node); - case 168 /* WhileStatement */: + case 175 /* WhileStatement */: return emitWhileStatement(node); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return emitForStatement(node); - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return emitForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return emitReturnStatement(node); - case 174 /* WithStatement */: + case 181 /* WithStatement */: return emitWithStatement(node); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return emitSwitchStatement(node); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return emitLabelledStatement(node); - case 179 /* ThrowStatement */: + case 184 /* ThrowStatement */: return emitThrowStatement(node); - case 180 /* TryStatement */: + case 185 /* TryStatement */: return emitTryStatement(node); - case 182 /* CatchBlock */: - return emitCatchBlock(node); - case 184 /* DebuggerStatement */: + case 203 /* CatchClause */: + return emitCatchClause(node); + case 188 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 185 /* VariableDeclaration */: + case 189 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return emitClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return emitImportDeclaration(node); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return emitSourceFile(node); } } @@ -9463,7 +10599,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 207 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -9480,7 +10616,7 @@ var ts; emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 207 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } @@ -9574,17 +10710,11 @@ var ts; writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } - var hasSemanticErrors = resolver.hasSemanticErrors(); - var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); - function emitFile(jsFilePath, sourceFile) { - if (!isEmitBlocked) { - emitJavaScript(jsFilePath, sourceFile); - if (!hasSemanticErrors && compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); - } - } - } + var hasSemanticErrors = false; + var isEmitBlocked = false; if (targetSourceFile === undefined) { + hasSemanticErrors = resolver.hasSemanticErrors(); + isEmitBlocked = resolver.isEmitBlocked(); ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); @@ -9597,13 +10727,29 @@ var ts; } else { if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile); + isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) { + hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile); + isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile); + } + }); emitFile(compilerOptions.out); } } + function emitFile(jsFilePath, sourceFile) { + if (!isEmitBlocked) { + emitJavaScript(jsFilePath, sourceFile); + if (!hasSemanticErrors && compilerOptions.declaration) { + writeDeclarationFile(jsFilePath, sourceFile); + } + } + } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); var hasEmitterError = ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1 /* Error */; }); @@ -9636,44 +10782,6 @@ var ts; var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - for (var i = 0; i < declarations.length; i++) { - var declaration = declarations[i]; - if (declaration.kind === kind) { - return declaration; - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length == 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - clear: function () { return str = ""; }, - trackSymbol: function () { - } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -9694,9 +10802,7 @@ var ts; getDiagnostics: getDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - checkProgram: checkProgram, - getParentOfSymbol: getParentOfSymbol, - getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol, + getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -9704,9 +10810,9 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, - getSymbolInfo: getSymbolInfo, + getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeOfNode: getTypeOfNode, + getTypeAtLocation: getTypeAtLocation, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -9723,17 +10829,17 @@ var ts; hasEarlyErrors: hasEarlyErrors, isEmitBlocked: isEmitBlocked }; - var undefinedSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "arguments"); - var unknownSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(268435456 /* Transient */, "__resolving__"); + var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 131072 /* Unwidened */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 131072 /* Unwidened */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var resolvingType = createIntrinsicType(1 /* Any */, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -9752,6 +10858,7 @@ var ts; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; + var anyArrayType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -9786,13 +10893,13 @@ var ts; if (flags & 16 /* Function */) result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 3258879 /* ClassExcludes */; + result |= 899583 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 3152288 /* InterfaceExcludes */; + result |= 792992 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 3258623 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 3259263 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 106639 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) @@ -9801,12 +10908,12 @@ var ts; result |= 41919 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) result |= 74687 /* SetAccessorExcludes */; - if (flags & 1048576 /* TypeParameter */) - result |= 2103776 /* TypeParameterExcludes */; - if (flags & 2097152 /* TypeAlias */) - result |= 3152352 /* TypeAliasExcludes */; - if (flags & 33554432 /* Import */) - result |= 33554432 /* ImportExcludes */; + if (flags & 262144 /* TypeParameter */) + result |= 530912 /* TypeParameterExcludes */; + if (flags & 524288 /* TypeAlias */) + result |= 793056 /* TypeAliasExcludes */; + if (flags & 8388608 /* Import */) + result |= 8388608 /* ImportExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -9815,7 +10922,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 134217728 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -9879,7 +10986,7 @@ var ts; } else { var symbol = target[id]; - if (!(symbol.flags & 134217728 /* Merged */)) { + if (!(symbol.flags & 33554432 /* Merged */)) { target[id] = symbol = cloneSymbol(symbol); } extendSymbol(symbol, source[id]); @@ -9888,7 +10995,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 268435456 /* Transient */) + if (symbol.flags & 67108864 /* Transient */) return symbol; if (!symbol.id) symbol.id = nextSymbolId++; @@ -9900,19 +11007,19 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 197 /* SourceFile */); + return ts.getAncestor(node, 207 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 207 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { var target = resolveImport(symbol); if (target === unknownSymbol || target.flags & meaning) { return symbol; @@ -9944,21 +11051,22 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { + case 195 /* ModuleDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { break loop; } break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 124 /* Property */: - if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + if (location.parent.kind === 191 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -9967,9 +11075,9 @@ var ts; } } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; @@ -9977,18 +11085,19 @@ var ts; break loop; } break; - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 152 /* FunctionExpression */: + case 156 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9999,8 +11108,8 @@ var ts; break loop; } break; - case 182 /* CatchBlock */: - var id = location.variable; + case 203 /* CatchClause */: + var id = location.name; if (name === id.text) { result = location.symbol; break loop; @@ -10036,12 +11145,12 @@ var ts; return result; } function resolveImport(symbol) { - ts.Debug.assert((symbol.flags & 33554432 /* Import */) !== 0, "Should only get Imports here."); + ts.Debug.assert((symbol.flags & 8388608 /* Import */) !== 0, "Should only get Imports here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */); - var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); + var node = ts.getDeclarationOfKind(symbol, 197 /* ImportDeclaration */); + var target = node.moduleReference.kind === 199 /* ExternalModuleReference */ ? resolveExternalModuleName(node, ts.getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -10056,25 +11165,28 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */); + importDeclaration = ts.getAncestor(entityName, 197 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 64 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + if (entityName.kind === 64 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */); - return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); + ts.Debug.assert(entityName.parent.kind === 197 /* ImportDeclaration */); + return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { - if (name.kind === 63 /* Identifier */) { + if (ts.getFullWidth(name) === 0) { + return undefined; + } + if (name.kind === 64 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; @@ -10082,7 +11194,7 @@ var ts; } else if (name.kind === 121 /* QualifiedName */) { var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); - if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) + if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -10090,18 +11202,19 @@ var ts; return; } } - else { - return; - } - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } - function resolveExternalModuleName(location, moduleLiteral) { + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).filename); - var moduleName = moduleLiteral.text; + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); if (!moduleName) return; var isRelative = isExternalModuleNameRelative(moduleName); @@ -10125,18 +11238,18 @@ var ts; if (sourceFile.symbol) { return getResolvedExportSymbol(sourceFile.symbol); } - error(moduleLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); return; } - error(moduleLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); if (symbol) { - if (symbol.flags & (107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */)) { + if (symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) { return symbol; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return resolveImport(symbol); } } @@ -10160,7 +11273,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } if (node.exportName.text) { - var meaning = 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */; + var meaning = 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */; var exportSymbol = resolveName(node, node.exportName.text, meaning, ts.Diagnostics.Cannot_find_name_0, node.exportName); } } @@ -10171,9 +11284,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 207 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 198 /* ExportAssignment */) { result.push(node); } else { @@ -10197,16 +11310,16 @@ var ts; return getMergedSymbol(symbol.parent); } function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 4194304 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; + return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { return symbolIsValue(getSymbolLinks(symbol).target); } if (symbol.flags & 107455 /* Value */) { return true; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return (resolveImport(symbol).flags & 107455 /* Value */) !== 0; } return false; @@ -10215,7 +11328,7 @@ var ts; var members = node.members; for (var i = 0; i < members.length; i++) { var member = members[i]; - if (member.kind === 126 /* Constructor */ && member.body) { + if (member.kind === 129 /* Constructor */ && member.body) { return member; } } @@ -10268,9 +11381,6 @@ var ts; function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; - } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; for (var location = enclosingDeclaration; location; location = location.parent) { @@ -10280,17 +11390,17 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -10320,8 +11430,8 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 33554432 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (symbolFromSymbolTable.flags & 8388608 /* Import */) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportDeclaration)) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -10348,7 +11458,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 33554432 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -10358,7 +11468,7 @@ var ts; return qualify; } function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { @@ -10403,7 +11513,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 195 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || (declaration.kind === 207 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10413,7 +11523,7 @@ var ts; return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 197 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -10432,51 +11542,44 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 135 /* TypeQuery */) { - meaning = 107455 /* Value */ | 4194304 /* ExportValue */; + if (entityName.parent.kind === 138 /* TypeQuery */) { + meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) { + else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 197 /* ImportDeclaration */) { meaning = 1536 /* Namespace */; } else { - meaning = 3152352 /* Type */; + meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return hasVisibleDeclarations(symbol) || { + return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } function writeKeyword(writer, kind) { writer.writeKeyword(ts.tokenToString(kind)); } function writePunctuation(writer, kind) { writer.writePunctuation(ts.tokenToString(kind)); } - function writeOperator(writer, kind) { - writer.writeOperator(ts.tokenToString(kind)); - } function writeSpace(writer) { writer.writeSpace(" "); } function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); return result; } function typeToString(type, enclosingDeclaration, flags) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { result = result.substr(0, maxLength - "...".length) + "..."; @@ -10486,10 +11589,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 140 /* ParenType */) { + while (node.kind === 143 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 190 /* TypeAliasDeclaration */) { + if (node.kind === 193 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -10512,14 +11615,14 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 19 /* DotToken */); + writePunctuation(writer, 20 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -10547,7 +11650,7 @@ var ts; } } } - if (enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { + if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { walkSymbol(symbol, meaning); return; } @@ -10564,7 +11667,7 @@ var ts; writeTypeReference(type, flags); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 3152352 /* Type */); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); @@ -10579,11 +11682,11 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 20 /* DotDotDotToken */); + writePunctuation(writer, 21 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); } } function writeTypeList(types, union) { @@ -10592,7 +11695,7 @@ var ts; if (union) { writeSpace(writer); } - writePunctuation(writer, union ? 43 /* BarToken */ : 22 /* CommaToken */); + writePunctuation(writer, union ? 44 /* BarToken */ : 23 /* CommaToken */); writeSpace(writer); } writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); @@ -10601,28 +11704,28 @@ var ts; function writeTypeReference(type, flags) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(type.typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 17 /* OpenBracketToken */); - writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writePunctuation(writer, 19 /* CloseBracketToken */); } else { - buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 3152352 /* Type */); - writePunctuation(writer, 23 /* LessThanToken */); + buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 793056 /* Type */); + writePunctuation(writer, 24 /* LessThanToken */); writeTypeList(type.typeArguments, false); - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function writeTupleType(type) { - writePunctuation(writer, 17 /* OpenBracketToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); writeTypeList(type.elementTypes, false); - writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 19 /* CloseBracketToken */); } function writeUnionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } writeTypeList(type.types, true); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -10635,10 +11738,10 @@ var ts; else if (typeStack && ts.contains(typeStack, type)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 3152352 /* Type */); + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */); } else { - writeKeyword(writer, 109 /* AnyKeyword */); + writeKeyword(writer, 110 /* AnyKeyword */); } } else { @@ -10652,7 +11755,7 @@ var ts; function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 207 /* SourceFile */ || declaration.parent.kind === 196 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10660,80 +11763,88 @@ var ts; } } function writeTypeofSymbol(type) { - writeKeyword(writer, 95 /* TypeOfKeyword */); + writeKeyword(writer, 96 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 13 /* OpenBraceToken */); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } - writeKeyword(writer, 86 /* NewKeyword */); + writeKeyword(writer, 87 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } return; } } - writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, 86 /* NewKeyword */); + writeKeyword(writer, 87 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 118 /* StringKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); + writeKeyword(writer, 119 /* StringKeyword */); + writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 116 /* NumberKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); + writeKeyword(writer, 117 /* NumberKeyword */); + writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { @@ -10743,28 +11854,28 @@ var ts; var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 50 /* QuestionToken */); } buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 50 /* QuestionToken */); } - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -10778,67 +11889,67 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 77 /* ExtendsKeyword */); + writeKeyword(writer, 78 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writePunctuation(writer, 20 /* DotDotDotToken */); + if (ts.hasDotDotDotToken(p.valueDeclaration)) { + writePunctuation(writer, 21 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writePunctuation(writer, 49 /* QuestionToken */); + if (ts.hasQuestionToken(p.valueDeclaration) || p.valueDeclaration.initializer) { + writePunctuation(writer, 50 /* QuestionToken */); } - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); + writePunctuation(writer, 24 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); + writePunctuation(writer, 24 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, typeStack) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 31 /* EqualsGreaterThanToken */); + writePunctuation(writer, 32 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); } writeSpace(writer); buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); @@ -10871,12 +11982,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 192 /* ModuleDeclaration */) { - if (node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 195 /* ModuleDeclaration */) { + if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 197 /* SourceFile */) { + else if (node.kind === 207 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10892,7 +12003,7 @@ var ts; if (isSymbolUsedInExportAssignment(symbolOfNode)) { return true; } - if (symbolOfNode.flags & 33554432 /* Import */) { + if (symbolOfNode.flags & 8388608 /* Import */) { return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode)); } } @@ -10900,17 +12011,17 @@ var ts; if (exportAssignmentSymbol === symbol) { return true; } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 33554432 /* Import */)) { + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Import */)) { resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol); if (resolvedExportSymbol === symbol) { return true; } - return ts.forEach(resolvedExportSymbol.declarations, function (declaration) { - while (declaration) { - if (declaration === node) { + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { return true; } - declaration = declaration.parent; + current = current.parent; } }); } @@ -10918,33 +12029,46 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 185 /* VariableDeclaration */: - case 192 /* ModuleDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 186 /* FunctionDeclaration */: - case 191 /* EnumDeclaration */: - case 194 /* ImportDeclaration */: - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 195 /* ModuleDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 190 /* FunctionDeclaration */: + case 194 /* EnumDeclaration */: + case 197 /* ImportDeclaration */: + var parent = getDeclarationContainer(node); + if (!(node.flags & 1 /* Export */) && !(node.kind !== 197 /* ImportDeclaration */ && parent.kind !== 207 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); - case 124 /* Property */: - case 125 /* Method */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; } - case 126 /* Constructor */: - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: - case 123 /* Parameter */: - case 193 /* ModuleBlock */: - case 122 /* TypeParameter */: + case 129 /* Constructor */: + case 133 /* ConstructSignature */: + case 132 /* CallSignature */: + case 134 /* IndexSignature */: + case 124 /* Parameter */: + case 196 /* ModuleBlock */: + case 123 /* TypeParameter */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 139 /* TypeLiteral */: + case 135 /* TypeReference */: + case 140 /* ArrayType */: + case 141 /* TupleType */: + case 142 /* UnionType */: + case 143 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10958,21 +12082,71 @@ var ts; return links.isVisible; } } + function getRootDeclaration(node) { + while (node.kind === 146 /* BindingElement */) { + node = node.parent.parent; + } + return node; + } + function getDeclarationContainer(node) { + node = getRootDeclaration(node); + return node.kind === 189 /* VariableDeclaration */ ? node.parent.parent : node.parent; + } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } - function getTypeOfVariableOrPropertyDeclaration(declaration) { - if (declaration.parent.kind === 170 /* ForInStatement */) { + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + if (parentType === unknownType) { + return unknownType; + } + if (!parentType || parentType === anyType) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + if (pattern.kind === 144 /* ObjectBindingPattern */) { + var name = declaration.propertyName || declaration.name; + var type = getTypeOfPropertyOfType(parentType, name.text) || isNumericName(name.text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); + return unknownType; + } + return type; + } + if (!isTypeAssignableTo(parentType, anyArrayType)) { + error(pattern, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(parentType)); + return unknownType; + } + var propName = "" + ts.indexOf(pattern.elements, declaration); + var type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : getIndexTypeOfType(parentType, 1 /* Number */); + if (!type) { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + return unknownType; + } + return type; + } + function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.parent.kind === 177 /* ForInStatement */) { return anyType; } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 123 /* Parameter */) { + if (declaration.kind === 124 /* Parameter */) { var func = declaration.parent; - if (func.kind === 128 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); + if (func.kind === 131 /* SetAccessor */ && !ts.hasComputedNameButNotSymbol(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 130 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10983,58 +12157,68 @@ var ts; } } if (declaration.initializer) { - var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 143 /* PropertyAssignment */) { - var unwidenedType = type; - type = getWidenedType(type); - if (type !== unwidenedType) { - checkImplicitAny(type); - } + return checkExpressionCached(declaration.initializer); + } + if (declaration.kind === 205 /* ShorthandPropertyAssignment */) { + return checkIdentifier(declaration.name); + } + return undefined; + } + function getTypeFromBindingElement(element) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name); + } + return anyType; + } + function getTypeFromBindingPattern(pattern) { + if (pattern.kind === 145 /* ArrayBindingPattern */) { + return createTupleType(ts.map(pattern.elements, function (e) { return e.kind === 167 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e); })); + } + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e); + members[symbol.name] = symbol; + }); + return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + } + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); } - return type; + return declaration.kind !== 204 /* PropertyAssignment */ ? getWidenedType(type) : type; } - if (declaration.kind === 144 /* ShorthandPropertyAssignment */) { - var type = checkIdentifier(declaration.name); - return type; + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } + type = declaration.dotDotDotToken ? anyArrayType : anyType; + if (reportErrors && compilerOptions.noImplicitAny) { + var root = getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 124 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } } - var type = declaration.flags & 8 /* Rest */ ? createArrayType(anyType) : anyType; - checkImplicitAny(type); return type; - function checkImplicitAny(type) { - if (!fullTypeCheck || !compilerOptions.noImplicitAny) { - return; - } - if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) { - return; - } - if (isPrivateWithinAmbient(declaration) || (declaration.kind === 123 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { - return; - } - switch (declaration.kind) { - case 124 /* Property */: - var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 123 /* Parameter */: - var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - default: - var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeToString(type)); - } } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 536870912 /* Prototype */) { + if (symbol.flags & 134217728 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 182 /* CatchBlock */) { + if (declaration.kind === 203 /* CatchClause */) { return links.type = anyType; } links.type = resolvingType; - var type = getTypeOfVariableOrPropertyDeclaration(declaration); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); if (links.type === resolvingType) { links.type = type; } @@ -11053,7 +12237,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 127 /* GetAccessor */) { + if (accessor.kind === 130 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -11072,8 +12256,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 130 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 131 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11103,7 +12287,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 130 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11137,7 +12321,7 @@ var ts; return links.type; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -11152,7 +12336,7 @@ var ts; if (symbol.flags & 98304 /* Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return getTypeOfImport(symbol); } return unknownType; @@ -11170,7 +12354,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */ || node.kind === 191 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -11201,9 +12385,10 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */); - if (declaration.baseType) { - var baseType = getTypeFromTypeReferenceNode(declaration.baseType); + var declaration = ts.getDeclarationOfKind(symbol, 191 /* ClassDeclaration */); + var baseTypeNode = ts.getClassBaseTypeNode(declaration); + if (baseTypeNode) { + var baseType = getTypeFromTypeReferenceNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -11214,7 +12399,7 @@ var ts; } } else { - error(declaration.baseType, ts.Diagnostics.A_class_may_only_extend_another_class); + error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); } } } @@ -11241,8 +12426,8 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) { - ts.forEach(declaration.baseTypes, function (node) { + if (declaration.kind === 192 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -11272,7 +12457,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 193 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -11280,7 +12465,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 193 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -11299,7 +12484,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 123 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11314,23 +12499,23 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & 32 /* Class */) { return getDeclaredTypeOfClass(symbol); } if (symbol.flags & 64 /* Interface */) { return getDeclaredTypeOfInterface(symbol); } - if (symbol.flags & 2097152 /* TypeAlias */) { + if (symbol.flags & 524288 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } if (symbol.flags & 384 /* Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 1048576 /* TypeParameter */) { + if (symbol.flags & 262144 /* TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return getDeclaredTypeOfImport(symbol); } return unknownType; @@ -11432,7 +12617,7 @@ var ts; function createTupleTypeMemberSymbols(memberTypes) { var members = {}; for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "" + i); + var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); symbol.type = memberTypes[i]; members[i] = symbol; } @@ -11629,7 +12814,7 @@ var ts; } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 268435456 /* Transient */ | 1073741824 /* UnionProperty */, name); + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* UnionProperty */, name); result.unionType = unionType; result.declarations = declarations; result.type = getUnionType(propTypes); @@ -11702,7 +12887,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 126 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 129 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; var hasStringLiterals = false; @@ -11710,11 +12895,11 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 7 /* StringLiteral */) { + if (param.type && param.type.kind === 8 /* StringLiteral */) { hasStringLiterals = true; } if (minArgumentCount < 0) { - if (param.initializer || param.flags & (4 /* QuestionMark */ | 8 /* Rest */)) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { minArgumentCount = i; } } @@ -11730,8 +12915,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 127 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); + if (declaration.kind === 130 /* GetAccessor */ && !ts.hasComputedNameButNotSymbol(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 131 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11749,18 +12934,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 126 /* Constructor */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11829,7 +13015,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 126 /* Constructor */ || signature.declaration.kind === 130 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 129 /* Constructor */ || signature.declaration.kind === 133 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -11843,7 +13029,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 116 /* NumberKeyword */ : 118 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 117 /* NumberKeyword */ : 119 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11870,7 +13056,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 123 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11891,11 +13077,15 @@ var ts; return result; } } + function getUnwidenedFlagOfTypes(types) { + return ts.forEach(types, function (t) { return t.flags & 131072 /* Unwidened */; }) || 0; + } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - type = target.instantiations[id] = createObjectType(4096 /* Reference */, target.symbol); + var flags = 4096 /* Reference */ | getUnwidenedFlagOfTypes(typeArguments); + type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; } @@ -11910,17 +13100,17 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 122 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 123 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 132 /* TypeReference */ && n.typeName.kind === 63 /* Identifier */) { + if (n.kind === 135 /* TypeReference */ && n.typeName.kind === 64 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 3152352 /* Type */, undefined, undefined); - if (symbol && (symbol.flags & 1048576 /* TypeParameter */)) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); } } @@ -11938,10 +13128,10 @@ var ts; function getTypeFromTypeReferenceNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var symbol = resolveEntityName(node, node.typeName, 3152352 /* Type */); + var symbol = resolveEntityName(node, node.typeName, 793056 /* Type */); if (symbol) { var type; - if ((symbol.flags & 1048576 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { type = unknownType; } else { @@ -11971,7 +13161,7 @@ var ts; function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); + links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); } return links.resolvedType; } @@ -11981,9 +13171,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: return declaration; } } @@ -12003,7 +13193,7 @@ var ts; return type; } function getGlobalSymbol(name) { - return resolveName(undefined, name, 3152352 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); + return resolveName(undefined, name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); } function getGlobalType(name) { return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0); @@ -12111,7 +13301,7 @@ var ts; var id = getTypeListId(sortedTypes); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getUnwidenedFlagOfTypes(sortedTypes)); type.types = sortedTypes; } return type; @@ -12131,8 +13321,9 @@ var ts; return links.resolvedType; } function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) + if (ts.hasProperty(stringLiteralTypes, node.text)) { return stringLiteralTypes[node.text]; + } var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); type.text = ts.getTextOfNode(node); return type; @@ -12146,35 +13337,35 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 109 /* AnyKeyword */: + case 110 /* AnyKeyword */: return anyType; - case 118 /* StringKeyword */: + case 119 /* StringKeyword */: return stringType; - case 116 /* NumberKeyword */: + case 117 /* NumberKeyword */: return numberType; - case 110 /* BooleanKeyword */: + case 111 /* BooleanKeyword */: return booleanType; - case 97 /* VoidKeyword */: + case 98 /* VoidKeyword */: return voidType; - case 7 /* StringLiteral */: + case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return getTypeFromTypeReferenceNode(node); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 138 /* TupleType */: + case 141 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 139 /* UnionType */: + case 142 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 136 /* TypeLiteral */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 139 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 63 /* Identifier */: + case 64 /* Identifier */: case 121 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); @@ -12269,12 +13460,12 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(67108864 /* Instantiated */ | 268435456 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -12318,22 +13509,31 @@ var ts; } return type; } - function isContextSensitiveExpression(node) { + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 142 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 143 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 141 /* ArrayLiteral */: - return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 157 /* ConditionalExpression */: - return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 156 /* BinaryExpression */: - return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 148 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 147 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 164 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); + case 163 /* BinaryExpression */: + return node.operator === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 204 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return isContextSensitiveFunctionLikeDeclaration(node); } return false; } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); + } function getTypeWithoutConstructors(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); @@ -12399,13 +13599,9 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (relation === identityRelation) { - if (source === target) - return -1 /* True */; - } - else { - if (source === target) - return -1 /* True */; + if (source === target) + return -1 /* True */; + if (relation !== identityRelation) { if (target.flags & 1 /* Any */) return -1 /* True */; if (source === undefinedType) @@ -12423,14 +13619,37 @@ var ts; return -1 /* True */; } } - if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; + if (source.flags & 16384 /* Union */ || target.flags & 16384 /* Union */) { + if (relation === identityRelation) { + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToUnionType(source, target)) { + if (result &= unionTypeRelatedToUnionType(target, source)) { + return result; + } + } + } + else if (source.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else { + if (result = unionTypeRelatedToType(target, source, reportErrors)) { + return result; + } + } } - } - else if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; + else { + if (source.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else { + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; + } + } } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { @@ -12458,6 +13677,18 @@ var ts; } return 0 /* False */; } + function unionTypeRelatedToUnionType(source, target) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = typeRelatedToUnionType(sourceTypes[i], target, false); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { @@ -12520,7 +13751,7 @@ var ts; if (overflow) { return 0 /* False */; } - var id = source.id + "," + target.id; + var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related ? -1 /* True */ : 0 /* False */; @@ -12610,14 +13841,14 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (relation === subtypeRelation || !isOptionalProperty(targetProp)) { + if (relation === subtypeRelation || !(targetProp.flags & 536870912 /* Optional */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0 /* False */; } } - else if (!(targetProp.flags & 536870912 /* Prototype */)) { + else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetFlags = getDeclarationFlagsFromSymbol(targetProp); if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { @@ -12658,7 +13889,7 @@ var ts; return 0 /* False */; } result &= related; - if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { + if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -12874,7 +14105,7 @@ var ts; } } else { - if (isOptionalProperty(sourceProp) !== isOptionalProperty(targetProp)) { + if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { return 0 /* False */; } } @@ -12961,74 +14192,108 @@ var ts; function isArrayType(type) { return type.flags & 4096 /* Reference */ && type.target === globalArrayType; } - function getInnermostTypeOfNestedArrayTypes(type) { - while (isArrayType(type)) { - type = type.typeArguments[0]; + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = getWidenedType(getTypeOfSymbol(p)); + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + members[symbol.name] = symbol; + }); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 131072 /* Unwidened */) { + if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { + return anyType; + } + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.map(type.types, function (t) { return getWidenedType(t); })); + } + if (isTypeOfObjectLiteral(type)) { + return getWidenedTypeOfObjectLiteral(type); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } } return type; } - function getWidenedType(type, suppressNoImplicitAnyErrors) { - if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { - return anyType; - } + function reportWideningErrorsInType(type) { if (type.flags & 16384 /* Union */) { - return getWidenedTypeOfUnion(type); - } - if (isTypeOfObjectLiteral(type)) { - return getWidenedTypeOfObjectLiteral(type); + var errorReported = false; + ts.forEach(type.types, function (t) { + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + }); + return errorReported; } if (isArrayType(type)) { - return getWidenedTypeOfArrayLiteral(type); + return reportWideningErrorsInType(type.typeArguments[0]); } - return type; - function getWidenedTypeOfUnion(type) { - return getUnionType(ts.map(type.types, function (t) { return getWidenedType(t, suppressNoImplicitAnyErrors); })); - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - if (properties.length) { - var widenedTypes = []; - var propTypeWasWidened = false; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - propTypeWasWidened = true; - if (!suppressNoImplicitAnyErrors && compilerOptions.noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType)); - } + if (isTypeOfObjectLiteral(type)) { + var errorReported = false; + ts.forEach(getPropertiesOfObjectType(type), function (p) { + var t = getTypeOfSymbol(p); + if (t.flags & 131072 /* Unwidened */) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } - widenedTypes.push(widenedType); - }); - if (propTypeWasWidened) { - var members = {}; - var index = 0; - ts.forEach(properties, function (p) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */ | p.flags, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedTypes[index++]; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - members[symbol.name] = symbol; - }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + errorReported = true; } - } - return type; + }); + return errorReported; } - function getWidenedTypeOfArrayLiteral(type) { - var elementType = type.typeArguments[0]; - var widenedType = getWidenedType(elementType, suppressNoImplicitAnyErrors); - type = elementType !== widenedType ? createArrayType(widenedType) : type; - return type; + return false; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + switch (declaration.kind) { + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 124 /* Parameter */: + var diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + var diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (fullTypeCheck && compilerOptions.noImplicitAny && type.flags & 131072 /* Unwidened */) { + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } } } function forEachMatchingParameterType(source, target, callback) { @@ -13230,16 +14495,16 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = (ts.getFullWidth(node) > 0 && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return true; - case 63 /* Identifier */: + case 64 /* Identifier */: case 121 /* QualifiedName */: node = node.parent; continue; @@ -13258,6 +14523,9 @@ var ts; } return type; } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } function isVariableAssignedWithin(symbol, node) { var links = getNodeLinks(node); if (links.assignmentChecks) { @@ -13271,99 +14539,129 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { + if (node.operator >= 52 /* FirstAssignment */ && node.operator <= 63 /* LastAssignment */) { var n = node.left; - while (n.kind === 151 /* ParenExpression */) { + while (n.kind === 155 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 64 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } return ts.forEachChild(node, isAssignedIn); } function isAssignedInVariableDeclaration(node) { - if (getSymbolOfNode(node) === symbol && node.initializer) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { return true; } return ts.forEachChild(node, isAssignedIn); } function isAssignedIn(node) { switch (node.kind) { - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 185 /* VariableDeclaration */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 161 /* PrefixUnaryExpression */: + case 158 /* DeleteExpression */: + case 159 /* TypeOfExpression */: + case 160 /* VoidExpression */: + case 162 /* PostfixUnaryExpression */: + case 164 /* ConditionalExpression */: + case 169 /* Block */: + case 170 /* VariableStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; } } + function resolveLocation(node) { + var containerNodes = []; + for (var parent = node.parent; parent; parent = parent.parent) { + if ((ts.isExpression(parent) || ts.isObjectLiteralMethod(node)) && isContextSensitive(parent)) { + containerNodes.unshift(parent); + } + } + ts.forEach(containerNodes, function (node) { + getTypeOfNode(node); + }); + } + function getSymbolAtLocation(node) { + resolveLocation(node); + return getSymbolInfo(node); + } + function getTypeAtLocation(node) { + resolveLocation(node); + return getTypeOfNode(node); + } + function getTypeOfSymbolAtLocation(symbol, node) { + resolveLocation(node); + return getNarrowedTypeOfSymbol(symbol, node); + } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */)) { - loop: while (true) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 166 /* IfStatement */: + case 173 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: if (child === node.right) { - if (node.operator === 47 /* AmpersandAmpersandToken */) { + if (node.operator === 48 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operator === 48 /* BarBarToken */) { + else if (node.operator === 49 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } break; - case 197 /* SourceFile */: - case 192 /* ModuleDeclaration */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: + case 207 /* SourceFile */: + case 195 /* ModuleDeclaration */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: break loop; } if (narrowedType !== type && isTypeSubtypeOf(narrowedType, type)) { @@ -13376,14 +14674,17 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 159 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + return type; + } var left = expr.left; var right = expr.right; - if (left.kind !== 154 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.expression.kind !== 64 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var t = right.text; var checkType = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; - if (expr.operator === 30 /* ExclamationEqualsEqualsToken */) { + if (expr.operator === 31 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { @@ -13416,7 +14717,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 63 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (!assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -13432,25 +14733,25 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: var operator = expr.operator; - if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { + if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 47 /* AmpersandAmpersandToken */) { + else if (operator === 48 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 48 /* BarBarToken */) { + else if (operator === 49 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 85 /* InstanceOfKeyword */) { + else if (operator === 86 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 154 /* PrefixOperator */: - if (expr.operator === 45 /* ExclamationToken */) { + case 161 /* PrefixUnaryExpression */: + if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -13460,18 +14761,17 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { getSymbolLinks(symbol).referenced = getSymbolLinks(symbol).referenced || (!isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol))); } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkCollisionWithIndexVariableInGeneratedCode(node, node); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 191 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { + if (container.kind === 126 /* PropertyDeclaration */ || container.kind === 129 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -13481,23 +14781,24 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 153 /* ArrowFunction */) { + if (container.kind === 157 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 126 /* Constructor */: + case 129 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } @@ -13506,7 +14807,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 191 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13519,31 +14820,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node; } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 123 /* Parameter */) { + if (n.kind === 124 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 151 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 191 /* ClassDeclaration */); var baseClass; - if (enclosingClass && enclosingClass.baseType) { + if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); baseClass = classType.baseTypes.length && classType.baseTypes[0]; } @@ -13555,20 +14858,20 @@ var ts; if (container) { var canUseSuperExpression = false; if (isCallExpression) { - canUseSuperExpression = container.kind === 126 /* Constructor */; + canUseSuperExpression = container.kind === 129 /* Constructor */; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 153 /* ArrowFunction */) { + while (container && container.kind === 157 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 191 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; + canUseSuperExpression = container.kind === 128 /* MethodDeclaration */ || container.kind === 127 /* MethodSignature */ || container.kind === 130 /* GetAccessor */ || container.kind === 131 /* SetAccessor */; } else { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */ || container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */; + canUseSuperExpression = container.kind === 128 /* MethodDeclaration */ || container.kind === 127 /* MethodSignature */ || container.kind === 130 /* GetAccessor */ || container.kind === 131 /* SetAccessor */ || container.kind === 126 /* PropertyDeclaration */ || container.kind === 125 /* PropertySignature */ || container.kind === 129 /* Constructor */; } } } @@ -13582,7 +14885,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 126 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 129 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -13601,9 +14904,9 @@ var ts; return unknownType; } function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (func.kind === 152 /* FunctionExpression */ || func.kind === 153 /* ArrowFunction */) { - if (isContextSensitiveExpression(func)) { + if (isFunctionExpressionOrArrowFunction(parameter.parent)) { + var func = parameter.parent; + if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var funcHasRestParameters = ts.hasRestParameters(func); @@ -13626,8 +14929,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 123 /* Parameter */) { - return getContextuallyTypedParameterType(declaration); + if (declaration.kind === 124 /* Parameter */) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); } } return undefined; @@ -13635,10 +14944,10 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { + if (func.type || func.kind === 129 /* Constructor */ || func.kind === 130 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 131 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } - var signature = getContextualSignature(func); + var signature = getContextualSignatureForFunctionLikeDeclaration(func); if (signature) { return getReturnTypeOfSignature(signature); } @@ -13657,12 +14966,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; - if (operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { + if (operator >= 52 /* FirstAssignment */ && operator <= 63 /* LastAssignment */) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 48 /* BarBarToken */) { + else if (operator === 49 /* BarBarToken */) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -13703,17 +15012,23 @@ var ts; function getIndexTypeOfContextualType(type, kind) { return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); } - function contextualTypeIsTupleType(type) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getPropertyOfObjectType(t, "0"); }) : getPropertyOfObjectType(type, "0")); + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return isTupleLikeType(t); }) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); } - function getContextualTypeForPropertyExpression(node) { - var declaration = node.parent; - var objectLiteral = declaration.parent; + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; var type = getContextualType(objectLiteral); - var name = declaration.name.text; + var name = element.name.text; if (type && name) { return getTypeOfPropertyOfContextualType(type, name) || isNumericName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || getIndexTypeOfContextualType(type, 0 /* String */); } @@ -13741,25 +15056,27 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: + case 189 /* VariableDeclaration */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 146 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 153 /* ArrowFunction */: - case 173 /* ReturnStatement */: + case 157 /* ArrowFunction */: + case 180 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return getContextualTypeForArgument(node); - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 143 /* PropertyAssignment */: - return getContextualTypeForPropertyExpression(node); - case 141 /* ArrayLiteral */: + case 204 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 147 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13773,8 +15090,15 @@ var ts; } } } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 156 /* FunctionExpression */ || node.kind === 157 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + } function getContextualSignature(node) { - var type = getContextualType(node); + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); if (!type) { return undefined; } @@ -13811,6 +15135,19 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper !== identityMapper; } + function isAssignmentTarget(node) { + var parent = node.parent; + if (parent.kind === 163 /* BinaryExpression */ && parent.operator === 52 /* EqualsToken */ && parent.left === node) { + return true; + } + if (parent.kind === 204 /* PropertyAssignment */) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 147 /* ArrayLiteralExpression */) { + return isAssignmentTarget(parent); + } + return false; + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; if (!elements.length) { @@ -13818,7 +15155,7 @@ var ts; } var elementTypes = ts.map(elements, function (e) { return checkExpression(e, contextualMapper); }); var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleType(contextualType)) { + if ((contextualType && contextualTypeIsTupleLikeType(contextualType)) || isAssignmentTarget(node)) { return createTupleType(elementTypes); } return createArrayType(getUnionType(elementTypes)); @@ -13830,34 +15167,39 @@ var ts; var members = node.symbol.members; var properties = {}; var contextualType = getContextualType(node); + var typeFlags; for (var id in members) { if (ts.hasProperty(members, id)) { var member = members[id]; - if (member.flags & 4 /* Property */) { + if (member.flags & 4 /* Property */ || ts.isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; - var type; - if (memberDecl.kind === 143 /* PropertyAssignment */) { - type = checkExpression(memberDecl.initializer, contextualMapper); + if (memberDecl.kind === 204 /* PropertyAssignment */) { + var type = checkExpression(memberDecl.initializer, contextualMapper); + } + else if (memberDecl.kind === 128 /* MethodDeclaration */) { + var type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 144 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 205 /* ShorthandPropertyAssignment */); + var type = memberDecl.name.kind === 122 /* ComputedPropertyName */ ? unknownType : checkExpression(memberDecl.name, contextualMapper); } - var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); + typeFlags |= type.flags; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; - if (member.valueDeclaration) + if (member.valueDeclaration) { prop.valueDeclaration = member.valueDeclaration; + } prop.type = type; prop.target = member; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); + var getAccessor = ts.getDeclarationOfKind(member, 130 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); + var setAccessor = ts.getDeclarationOfKind(member, 131 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13867,7 +15209,9 @@ var ts; } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); - return createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); + result.flags |= (typeFlags & 131072 /* Unwidened */); + return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { var propTypes = []; @@ -13887,17 +15231,17 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 124 /* Property */; + return s.valueDeclaration ? s.valueDeclaration.kind : 126 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } - function checkClassPropertyAccess(node, type, prop) { + function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 191 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13906,7 +15250,7 @@ var ts; } return; } - if (node.left.kind === 89 /* SuperKeyword */) { + if (left.kind === 90 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13920,8 +15264,14 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); } } - function checkPropertyAccess(node) { - var type = checkExpression(node.left); + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpressionOrQualifiedName(left); if (type === unknownType) return type; if (type !== anyType) { @@ -13929,20 +15279,20 @@ var ts; if (apparentType === unknownType) { return unknownType; } - var prop = getPropertyOfType(apparentType, node.right.text); + var prop = getPropertyOfType(apparentType, right.text); if (!prop) { - if (node.right.text) { - error(node.right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(node.right), typeToString(type)); + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === 90 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 128 /* MethodDeclaration */) { + error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); } } return getTypeOfSymbol(prop); @@ -13950,16 +15300,17 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var type = checkExpression(node.left); + var left = node.kind === 149 /* PropertyAccessExpression */ ? node.expression : node.left; + var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + if (left.kind === 90 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 128 /* MethodDeclaration */) { return false; } else { var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); return diagnostics.length === diagnosticsCount; } } @@ -13967,19 +15318,22 @@ var ts; return true; } function checkIndexedAccess(node) { - var objectType = getApparentType(checkExpression(node.object)); - var indexType = checkExpression(node.index); - if (objectType === unknownType) + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { return unknownType; - if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { - error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); } - if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { - var name = node.index.text; - var prop = getPropertyOfType(objectType, name); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); + if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== 8 /* StringLiteral */) { + error(node.argumentExpression, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } + if (node.argumentExpression) { + if (node.argumentExpression.kind === 8 /* StringLiteral */ || node.argumentExpression.kind === 7 /* NumericLiteral */) { + var name = node.argumentExpression.text; + var prop = getPropertyOfType(objectType, name); + if (prop) { + getNodeLinks(node).resolvedSymbol = prop; + return getTypeOfSymbol(prop); + } } } if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { @@ -13993,7 +15347,7 @@ var ts; if (stringIndexType) { return stringIndexType; } - if (compilerOptions.noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } return anyType; @@ -14002,7 +15356,7 @@ var ts; return unknownType; } function resolveUntypedCall(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -14020,26 +15374,26 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 158 /* TemplateExpression */) { + if (tagExpression.template.kind === 165 /* TemplateExpression */) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = lastSpan.literal.kind === 120 /* Missing */ || ts.isUnterminatedTemplateEnd(lastSpan.literal); + callIsIncomplete = ts.getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 9 /* NoSubstitutionTemplateLiteral */); - callIsIncomplete = ts.isUnterminatedTemplateEnd(templateLiteral); + ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + callIsIncomplete = !!templateLiteral.isUnterminated; } } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 148 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 152 /* NewExpression */); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -14082,12 +15436,12 @@ var ts; var context = createInferenceContext(typeParameters, false); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { + if (args[i].kind === 167 /* OmittedExpression */) { continue; } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); - if (i === 0 && args[i].parent.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 153 /* TaggedTemplateExpression */) { inferTypes(context, globalTemplateStringsArrayType, parameterType); continue; } @@ -14096,7 +15450,7 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { + if (args[i].kind === 167 /* OmittedExpression */) { continue; } if (excludeArgument[i] === false) { @@ -14134,15 +15488,15 @@ var ts; for (var i = 0; i < args.length; i++) { var arg = args[i]; var argType; - if (arg.kind === 161 /* OmittedExpression */) { + if (arg.kind === 167 /* OmittedExpression */) { continue; } var paramType = getTypeAtPosition(signature, i); - if (i === 0 && node.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && node.kind === 153 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { - argType = arg.kind === 7 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + argType = arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1); if (!isValidArgument) { @@ -14153,10 +15507,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 165 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -14168,7 +15522,7 @@ var ts; return args; } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 149 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 153 /* TaggedTemplateExpression */; var typeArguments = isTaggedTemplate ? undefined : node.typeArguments; ts.forEach(typeArguments, checkSourceElement); var candidates = candidatesOutArray || []; @@ -14180,7 +15534,7 @@ var ts; var args = getEffectiveCallArguments(node); var excludeArgument; for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitiveExpression(args[i])) { + if (isContextSensitive(args[i])) { if (!excludeArgument) { excludeArgument = new Array(args.length); } @@ -14215,7 +15569,7 @@ var ts; var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, node.func || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { @@ -14316,14 +15670,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 89 /* SuperKeyword */) { - var superType = checkSuperExpression(node.func); + if (node.expression.kind === 90 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } - var funcType = checkExpression(node.func); + var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); if (apparentType === unknownType) { return resolveErrorCall(node); @@ -14348,7 +15702,7 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function resolveNewExpression(node, candidatesOutArray) { - var expressionType = checkExpression(node.func); + var expressionType = checkExpression(node.expression); if (expressionType === anyType) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -14394,13 +15748,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 147 /* CallExpression */) { + if (node.kind === 151 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 148 /* NewExpression */) { + else if (node.kind === 152 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 153 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14411,12 +15765,12 @@ var ts; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 90 /* SuperKeyword */) { return voidType; } - if (node.kind === 148 /* NewExpression */) { + if (node.kind === 152 /* NewExpression */) { var declaration = signature.declaration; - if (declaration && declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */ && declaration.kind !== 134 /* ConstructorType */) { + if (declaration && declaration.kind !== 129 /* Constructor */ && declaration.kind !== 133 /* ConstructSignature */ && declaration.kind !== 137 /* ConstructorType */) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -14429,10 +15783,10 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkTypeAssertion(node) { - var exprType = checkExpression(node.operand); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (fullTypeCheck && targetType !== unknownType) { - var widenedType = getWidenedType(exprType, true); + var widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -14456,42 +15810,32 @@ var ts; } } function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 187 /* FunctionBlock */) { - var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); - var widenedType = getWidenedType(unwidenedType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType)); - } - return widenedType; + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (func.body.kind !== 169 /* Block */) { + var type = checkExpressionCached(func.body, contextualMapper); } - var types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); - if (types.length > 0) { - var commonType = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!commonType) { + else { + var types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + if (types.length === 0) { + return voidType; + } + var type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); return unknownType; } - var widenedType = getWidenedType(commonType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - var typeName = typeToString(widenedType); - if (func.name) { - error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(func.name), typeName); - } - else { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } - return widenedType; } - return voidType; + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + return getWidenedType(type); } function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkAndMarkExpression(expr, contextualMapper); + var type = checkExpressionCached(expr, contextualMapper); if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -14505,7 +15849,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 184 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -14514,7 +15858,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 187 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 169 /* Block */) { return; } var bodyBlock = func.body; @@ -14526,7 +15870,8 @@ var ts; } error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } - function checkFunctionExpression(node, contextualMapper) { + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (contextualMapper === identityMapper) { return anyFunctionType; } @@ -14538,7 +15883,7 @@ var ts; links.flags |= 64 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitiveExpression(node)) { + if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } if (!node.type) { @@ -14552,21 +15897,28 @@ var ts; checkSignatureDeclaration(node); } } + if (fullTypeCheck && node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } return type; } - function checkFunctionExpressionBody(node) { + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 187 /* FunctionBlock */) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (node.body) { + if (node.body.kind === 169 /* Block */) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (node.type) { + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + } + checkFunctionExpressionBodies(node.body); } - checkFunctionExpressionBodies(node.body); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -14583,15 +15935,15 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - case 145 /* PropertyAccess */: + case 149 /* PropertyAccessExpression */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 146 /* IndexedAccess */: + case 150 /* ElementAccessExpression */: return true; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14599,20 +15951,20 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 149 /* PropertyAccessExpression */: var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 146 /* IndexedAccess */: - var index = n.index; - var symbol = findSymbol(n.object); - if (symbol && index.kind === 7 /* StringLiteral */) { + case 150 /* ElementAccessExpression */: + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 8 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -14628,22 +15980,29 @@ var ts; } return true; } - function checkPrefixExpression(node) { + function checkDeleteExpression(node) { + var operandType = checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + var operandType = checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + var operandType = checkExpression(node.expression); + return undefinedType; + } + function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: return numberType; - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: + case 46 /* ExclamationToken */: return booleanType; - case 95 /* TypeOfKeyword */: - return stringType; - case 97 /* VoidKeyword */: - return undefinedType; - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -14652,7 +16011,7 @@ var ts; } return unknownType; } - function checkPostfixExpression(node) { + function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -14664,7 +16023,7 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & 65025 /* Structured */) !== 0; + return (type.flags & (48128 /* ObjectType */ | 512 /* TypeParameter */)) !== 0; } function isConstEnumObjectType(type) { return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); @@ -14673,10 +16032,10 @@ var ts; return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (leftType !== unknownType && !isStructuredType(leftType)) { + if (!(leftType.flags & 1 /* Any */ || isStructuredType(leftType))) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (!(rightType.flags & 1 /* Any */ || isTypeSubtypeOf(rightType, globalFunctionType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -14685,36 +16044,97 @@ var ts; if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); } - if (!isStructuredType(rightType)) { + if (!(rightType.flags & 1 /* Any */ || isStructuredType(rightType))) { error(node.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, contextualMapper) { + var properties = node.properties; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 204 /* PropertyAssignment */ || p.kind === 205 /* ShorthandPropertyAssignment */) { + var name = p.name; + var type = sourceType.flags & 1 /* Any */ ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || isNumericName(name.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); + if (type) { + checkDestructuringAssignment(p.initializer || name, type); + } + else { + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + if (!isTypeAssignableTo(sourceType, anyArrayType)) { + error(node, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(sourceType)); + return sourceType; + } + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 167 /* OmittedExpression */) { + var propName = "" + i; + var type = sourceType.flags & 1 /* Any */ ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : getIndexTypeOfType(sourceType, 1 /* Number */); + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + return sourceType; + } + function checkDestructuringAssignment(target, sourceType, contextualMapper) { + if (target.kind === 163 /* BinaryExpression */ && target.operator === 52 /* EqualsToken */) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 148 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 147 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, undefined); + } + return sourceType; + } function checkBinaryExpression(node, contextualMapper) { var operator = node.operator; + if (operator === 52 /* EqualsToken */ && (node.left.kind === 148 /* ObjectLiteralExpression */ || node.left.kind === 147 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 34 /* AsteriskToken */: - case 54 /* AsteriskEqualsToken */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 36 /* PercentToken */: - case 56 /* PercentEqualsToken */: - case 33 /* MinusToken */: - case 53 /* MinusEqualsToken */: - case 39 /* LessThanLessThanToken */: - case 57 /* LessThanLessThanEqualsToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 58 /* GreaterThanGreaterThanEqualsToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: + case 35 /* AsteriskToken */: + case 55 /* AsteriskEqualsToken */: + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + case 37 /* PercentToken */: + case 57 /* PercentEqualsToken */: + case 34 /* MinusToken */: + case 54 /* MinusEqualsToken */: + case 40 /* LessThanLessThanToken */: + case 58 /* LessThanLessThanEqualsToken */: + case 41 /* GreaterThanGreaterThanToken */: + case 59 /* GreaterThanGreaterThanEqualsToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* BarToken */: + case 62 /* BarEqualsToken */: + case 45 /* CaretToken */: + case 63 /* CaretEqualsToken */: + case 43 /* AmpersandToken */: + case 61 /* AmpersandEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -14731,8 +16151,8 @@ var ts; } } return numberType; - case 32 /* PlusToken */: - case 52 /* PlusEqualsToken */: + case 33 /* PlusToken */: + case 53 /* PlusEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -14751,53 +16171,53 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 52 /* PlusEqualsToken */) { + if (operator === 53 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: + case 28 /* EqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: + case 24 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 26 /* LessThanEqualsToken */: + case 27 /* GreaterThanEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 85 /* InstanceOfKeyword */: + case 86 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 84 /* InKeyword */: + case 85 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 47 /* AmpersandAmpersandToken */: + case 48 /* AmpersandAmpersandToken */: return rightType; - case 48 /* BarBarToken */: + case 49 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 51 /* EqualsToken */: + case 52 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; - case 22 /* CommaToken */: + case 23 /* CommaToken */: return rightType; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - return 48 /* BarBarToken */; - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - return 30 /* ExclamationEqualsEqualsToken */; - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: - return 47 /* AmpersandAmpersandToken */; + case 44 /* BarToken */: + case 62 /* BarEqualsToken */: + return 49 /* BarBarToken */; + case 45 /* CaretToken */: + case 63 /* CaretEqualsToken */: + return 31 /* ExclamationEqualsEqualsToken */; + case 43 /* AmpersandToken */: + case 61 /* AmpersandEqualsToken */: + return 48 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (fullTypeCheck && operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { + if (fullTypeCheck && operator >= 52 /* FirstAssignment */ && operator <= 63 /* LastAssignment */) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14827,13 +16247,18 @@ var ts; node.contextualType = saveContextualType; return result; } - function checkAndMarkExpression(node, contextualMapper) { - var result = checkExpression(node, contextualMapper); - getNodeLinks(node).flags |= 1 /* TypeChecked */; - return result; + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; } - function checkExpression(node, contextualMapper) { - var type = checkExpressionNode(node, contextualMapper); + function checkObjectLiteralMethod(node, contextualMapper) { + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { if (contextualMapper && contextualMapper !== identityMapper) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { @@ -14841,72 +16266,90 @@ var ts; if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); } } } } + return type; + } + function checkExpression(node, contextualMapper) { + return checkExpressionOrQualifiedName(node, contextualMapper); + } + function checkExpressionOrQualifiedName(node, contextualMapper) { + var type; + if (node.kind == 121 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 145 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 146 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 149 /* PropertyAccessExpression */ && node.parent.expression === node) || (node.parent.kind === 150 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 64 /* Identifier */ || node.kind === 121 /* 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 checkExpressionNode(node, contextualMapper) { + function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: return checkIdentifier(node); - case 91 /* ThisKeyword */: + case 92 /* ThisKeyword */: return checkThisExpression(node); - case 89 /* SuperKeyword */: + case 90 /* SuperKeyword */: return checkSuperExpression(node); - case 87 /* NullKeyword */: + case 88 /* NullKeyword */: return nullType; - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: return booleanType; - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: return numberType; - case 158 /* TemplateExpression */: + case 165 /* TemplateExpression */: return checkTemplateExpression(node); - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: return stringType; - case 8 /* RegularExpressionLiteral */: + case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 121 /* QualifiedName */: - return checkPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 147 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 145 /* PropertyAccess */: - return checkPropertyAccess(node); - case 146 /* IndexedAccess */: + case 149 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 150 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return checkCallExpression(node); - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return checkExpression(node.expression); - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return checkFunctionExpression(node, contextualMapper); - case 154 /* PrefixOperator */: - return checkPrefixExpression(node); - case 155 /* PostfixOperator */: - return checkPostfixExpression(node); - case 156 /* BinaryExpression */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 159 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 158 /* DeleteExpression */: + return checkDeleteExpression(node); + case 160 /* VoidExpression */: + return checkVoidExpression(node); + case 161 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 162 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 163 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 161 /* OmittedExpression */: + case 167 /* OmittedExpression */: return undefinedType; } return unknownType; @@ -14918,47 +16361,19 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } - function checkParameter(parameterDeclaration) { - checkVariableDeclaration(parameterDeclaration); - if (fullTypeCheck) { - checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - if (parameterDeclaration.flags & 8 /* Rest */) { - if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) { - error(parameterDeclaration, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - else { - if (parameterDeclaration.initializer && !parameterDeclaration.parent.body) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - } + function checkParameter(node) { + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */)) { + func = ts.getContainingFunction(node); + if (!(func.kind === 129 /* Constructor */ && func.body)) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } - function checkReferencesInInitializer(n) { - if (n.kind === 63 /* Identifier */) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 123 /* Parameter */) { - if (referencedSymbol.valueDeclaration === parameterDeclaration) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(parameterDeclaration.name)); - return; - } - var enclosingOrReferencedParameter = ts.forEach(parameterDeclaration.parent.parameters, function (p) { return p === parameterDeclaration || p === referencedSymbol.valueDeclaration ? p : undefined; }); - if (enclosingOrReferencedParameter === referencedSymbol.valueDeclaration) { - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(parameterDeclaration.name), ts.declarationNameToString(n)); - } + if (node.dotDotDotToken) { + if (!isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } - else { - ts.forEachChild(n, checkReferencesInInitializer); - } - } - if (parameterDeclaration.initializer) { - checkReferencesInInitializer(parameterDeclaration.initializer); } } function checkSignatureDeclaration(node) { @@ -14968,16 +16383,13 @@ var ts; checkSourceElement(node.type); } if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14986,7 +16398,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14998,9 +16410,9 @@ var ts; var seenStringIndexer = false; for (var i = 0, len = indexSymbol.declarations.length; i < len; ++i) { var declaration = indexSymbol.declarations[i]; - if (declaration.parameters.length == 1 && declaration.parameters[0].type) { + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 118 /* StringKeyword */: + case 119 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -15008,7 +16420,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 116 /* NumberKeyword */: + case 117 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -15022,16 +16434,16 @@ var ts; } } function checkPropertyDeclaration(node) { - checkVariableDeclaration(node); + checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(symbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(symbol); } @@ -15042,37 +16454,37 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 147 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; + return n.kind === 151 /* CallExpression */ && n.expression.kind === 90 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 142 /* ObjectLiteral */: return false; + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + case 148 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 91 /* ThisKeyword */) { + if (n.kind === 92 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) { + else if (n.kind !== 156 /* FunctionExpression */ && n.kind !== 190 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; + return n.kind === 126 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } - if (node.parent.baseType) { + if (ts.getClassBaseTypeNode(node.parent)) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 172 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -15087,28 +16499,30 @@ var ts; } function checkAccessorDeclaration(node) { if (fullTypeCheck) { - if (node.kind === 127 /* GetAccessor */) { + if (node.kind === 130 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; - var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + if (!ts.hasComputedNameButNotSymbol(node)) { + var otherKind = node.kind === 130 /* GetAccessor */ ? 131 /* SetAccessor */ : 130 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } } } + checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); } } - checkFunctionDeclaration(node); - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + checkFunctionLikeDeclaration(node); } function checkTypeReference(node) { var type = getTypeFromTypeReferenceNode(node); @@ -15160,9 +16574,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 192 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 132 /* CallSignature */ || signatureDeclarationNode.kind === 133 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 132 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -15180,7 +16594,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 192 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -15192,11 +16606,14 @@ var ts; if (!fullTypeCheck) { return; } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - var canonicalFlags = implementationSharesContainerWithFirstOverload ? getEffectiveDeclarationFlags(implementation, flagsToCheck) : getEffectiveDeclarationFlags(overloads[0], flagsToCheck); + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & 1 /* Export */) { @@ -15208,15 +16625,25 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 4 /* QuestionMark */) { + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 4 /* QuestionMark */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; var hasOverloads = false; var bodyDeclaration; var lastSeenNonAmbientDeclaration; @@ -15224,7 +16651,7 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 120 /* Missing */) { + if (node.name && ts.getFullWidth(node.name) === 0) { return; } var seen = false; @@ -15240,7 +16667,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 125 /* Method */); + ts.Debug.assert(node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); @@ -15266,14 +16693,16 @@ var ts; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 192 /* InterfaceDeclaration */ || node.parent.kind === 139 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { + if (node.kind === 190 /* FunctionDeclaration */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 129 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); if (node.body && bodyDeclaration) { if (isConstructor) { multipleConstructorImplementation = true; @@ -15314,6 +16743,7 @@ var ts; } if (hasOverloads) { checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -15336,11 +16766,11 @@ var ts; var symbol = node.localSymbol; if (!symbol) { symbol = getSymbolOfNode(node); - if (!(symbol.flags & 29360128 /* Export */)) { + if (!(symbol.flags & 7340032 /* Export */)) { return; } } - if (getDeclarationOfKind(symbol, node.kind) !== node) { + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } var exportedDeclarationSpaces = 0; @@ -15364,14 +16794,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 189 /* InterfaceDeclaration */: - return 8388608 /* ExportType */; - case 192 /* ModuleDeclaration */: - return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - return 8388608 /* ExportType */ | 4194304 /* ExportValue */; - case 194 /* ImportDeclaration */: + case 192 /* InterfaceDeclaration */: + return 2097152 /* ExportType */; + case 195 /* ModuleDeclaration */: + return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + return 2097152 /* ExportType */ | 1048576 /* ExportValue */; + case 197 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -15379,113 +16809,83 @@ var ts; }); return result; default: - return 4194304 /* ExportValue */; + return 1048576 /* ExportValue */; } } } function checkFunctionDeclaration(node) { - checkSignatureDeclaration(node); - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); + checkFunctionLikeDeclaration(node); + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } - if (symbol.parent) { - if (getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); + } + function checkFunctionLikeDeclaration(node) { + checkSignatureDeclaration(node); + if (!ts.hasComputedNameButNotSymbol(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } } } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind)) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) { - if (!isPrivateWithinAmbient(node)) { - var typeName = typeToString(anyType); - if (node.name) { - error(node, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(node.name), typeName); - } - else { - error(node, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } + if (compilerOptions.noImplicitAny && !node.body && !node.type && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); } } function checkBlock(node) { ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 196 /* ModuleBlock */) { + checkFunctionExpressionBodies(node); + } } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) { return; } ts.forEach(node.parameters, function (p) { - if (p.name && p.name.text === argumentsSymbol.name) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); } }); } - function checkCollisionWithIndexVariableInGeneratedCode(node, name) { - if (!(name && name.text === "_i")) { - return; - } - if (node.kind === 123 /* Parameter */) { - if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) { - error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); - } - return; - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol === unknownSymbol) { - return; - } - var current = node; - while (current) { - var definedOnCurrentLevel = ts.forEach(symbol.declarations, function (d) { return d.parent === current ? d : undefined; }); - if (definedOnCurrentLevel) { - return; - } - switch (current.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - if (ts.hasRestParameters(current)) { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); - return; - } - break; - } - current = current.parent; - } - } function needCollisionCheckForIdentifier(node, identifier, name) { if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { + if (node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 130 /* GetAccessor */ || node.kind === 131 /* SetAccessor */) { return false; } if (ts.isInAmbientContext(node)) { return false; } - if (node.kind === 123 /* Parameter */ && !node.parent.body) { + var root = getRootDeclaration(node); + if (root.kind === 124 /* Parameter */ && !root.parent.body) { return false; } return true; } function checkCollisionWithCapturedThisVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); } - potentialThisCollisions.push(node); } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration = node.kind !== 63 /* Identifier */; + var isDeclaration = node.kind !== 64 /* Identifier */; if (isDeclaration) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -15501,12 +16901,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 191 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } - if (enclosingClass.baseType) { - var isDeclaration = node.kind !== 63 /* Identifier */; + if (ts.getClassBaseTypeNode(enclosingClass)) { + var isDeclaration = node.kind !== 64 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -15519,11 +16919,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 195 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = getDeclarationContainer(node); + if (parent.kind === 207 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -15540,38 +16940,87 @@ var ts; } } } - function checkVariableDeclaration(node) { - checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); - if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - var type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; + function isParameterDeclaration(node) { + while (node.kind === 146 /* BindingElement */) { + node = node.parent.parent; + } + return node.kind === 124 /* Parameter */; + } + function checkParameterInitializer(node) { + if (getRootDeclaration(node).kind === 124 /* Parameter */) { + var func = ts.getContainingFunction(node); + visit(node.initializer); + } + function visit(n) { + if (n.kind === 64 /* Identifier */) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 124 /* Parameter */) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } } else { - type = getTypeOfVariableOrPropertyDeclaration(node); - } - if (node.initializer) { - if (!(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); - } - checkCollisionWithConstDeclarations(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - if (!useTypeFromValueDeclaration) { - if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { - error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); - } + ts.forEachChild(n, visit); } } } + function checkVariableLikeDeclaration(node) { + checkSourceElement(node.type); + if (ts.hasComputedNameButNotSymbol(node)) { + if (node.initializer) { + checkExpressionCached(node.initializer); + } + return; + } + if (ts.isBindingPattern(node.name)) { + ts.forEach(node.name.elements, checkSourceElement); + } + if (node.initializer && getRootDeclaration(node).kind === 124 /* Parameter */ && !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) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkParameterInitializer(node); + } + } + else { + var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { + error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + } + } + if (node.kind !== 126 /* PropertyDeclaration */ && node.kind !== 125 /* PropertySignature */) { + checkExportsOnMergedDeclarations(node); + checkCollisionWithConstDeclarations(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } function checkVariableStatement(node) { - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkSourceElement); } function checkExpressionStatement(node) { checkExpression(node.expression); @@ -15591,7 +17040,7 @@ var ts; } function checkForStatement(node) { if (node.declarations) - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableLikeDeclaration); if (node.initializer) checkExpression(node.initializer); if (node.condition) @@ -15604,7 +17053,7 @@ var ts; if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; - checkVariableDeclaration(decl); + checkVariableLikeDeclaration(decl); if (decl.type) { error(decl, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); } @@ -15620,33 +17069,34 @@ var ts; } } var exprType = checkExpression(node.expression); - if (!isStructuredType(exprType) && exprType !== unknownType) { + if (!(exprType.flags & 1 /* Any */ || isStructuredType(exprType))) { 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); } function checkBreakOrContinueStatement(node) { } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 130 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 131 /* SetAccessor */))); + } function checkReturnStatement(node) { - if (node.expression && !(getNodeLinks(node.expression).flags & 1 /* TypeChecked */)) { + if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - if (func.kind === 128 /* SetAccessor */) { - if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var exprType = checkExpressionCached(node.expression); + if (func.kind === 131 /* SetAccessor */) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); - if (checkAssignability) { - checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); - } - else if (func.kind == 126 /* Constructor */) { - if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) { + if (func.kind === 129 /* Constructor */) { + if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + } } } } @@ -15658,25 +17108,28 @@ var ts; function checkSwitchStatement(node) { var expressionType = checkExpression(node.expression); ts.forEach(node.clauses, function (clause) { - if (fullTypeCheck && clause.expression) { - var caseType = checkExpression(clause.expression); + if (fullTypeCheck && clause.kind === 200 /* CaseClause */) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, clause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); } } - checkBlock(clause); + ts.forEach(clause.statements, checkSourceElement); }); } function checkLabeledStatement(node) { checkSourceElement(node.statement); } function checkThrowStatement(node) { - checkExpression(node.expression); + if (node.expression) { + checkExpression(node.expression); + } } function checkTryStatement(node) { checkBlock(node.tryBlock); - if (node.catchBlock) - checkBlock(node.catchBlock); + if (node.catchClause) + checkBlock(node.catchClause.block); if (node.finallyBlock) checkBlock(node.finallyBlock); } @@ -15761,9 +17214,10 @@ var ts; var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); var staticType = getTypeOfSymbol(symbol); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkTypeReference(node.baseType); + checkTypeReference(baseTypeNode); } if (type.baseTypes.length) { if (fullTypeCheck) { @@ -15771,15 +17225,16 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { - error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, 107455 /* Value */)) { + error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); } - checkExpression(node.baseType.typeName); + checkExpressionOrQualifiedName(baseTypeNode.typeName); } - if (node.implementedTypes) { - ts.forEach(node.implementedTypes, function (typeRefNode) { + var implementedTypeNodes = ts.getClassImplementedTypeNodes(node); + if (implementedTypeNodes) { + ts.forEach(implementedTypeNodes, function (typeRefNode) { checkTypeReference(typeRefNode); if (fullTypeCheck) { var t = getTypeFromTypeReferenceNode(typeRefNode); @@ -15802,13 +17257,13 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 67108864 /* Instantiated */ ? getSymbolLinks(s).target : s; + return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); for (var i = 0, len = baseProperties.length; i < len; ++i) { var base = getTargetSymbol(baseProperties[i]); - if (base.flags & 536870912 /* Prototype */) { + if (base.flags & 134217728 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -15848,7 +17303,7 @@ var ts; } } function isAccessor(kind) { - return kind === 127 /* GetAccessor */ || kind === 128 /* SetAccessor */; + return kind === 130 /* GetAccessor */ || kind === 131 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15914,7 +17369,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 192 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15930,7 +17385,7 @@ var ts; } } } - ts.forEach(node.baseTypes, checkTypeReference); + ts.forEach(ts.getInterfaceBaseTypeNodes(node), checkTypeReference); ts.forEach(node.members, checkSourceElement); if (fullTypeCheck) { checkTypeForDuplicateIndexSignatures(node); @@ -15985,18 +17440,18 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 154 /* PrefixOperator */: + case 161 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 32 /* PlusToken */: return value; - case 33 /* MinusToken */: return -value; - case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; + case 33 /* PlusToken */: return value; + case 34 /* MinusToken */: return -value; + case 47 /* TildeToken */: return enumIsConst ? ~value : undefined; } return undefined; - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: if (!enumIsConst) { return undefined; } @@ -16009,26 +17464,26 @@ var ts; return undefined; } switch (e.operator) { - case 43 /* BarToken */: return left | right; - case 42 /* AmpersandToken */: return left & right; - case 40 /* GreaterThanGreaterThanToken */: return left >> right; - case 41 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 39 /* LessThanLessThanToken */: return left << right; - case 44 /* CaretToken */: return left ^ right; - case 34 /* AsteriskToken */: return left * right; - case 35 /* SlashToken */: return left / right; - case 32 /* PlusToken */: return left + right; - case 33 /* MinusToken */: return left - right; - case 36 /* PercentToken */: return left % right; + case 44 /* BarToken */: return left | right; + case 43 /* AmpersandToken */: return left & right; + case 41 /* GreaterThanGreaterThanToken */: return left >> right; + case 42 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 40 /* LessThanLessThanToken */: return left << right; + case 45 /* CaretToken */: return left ^ right; + case 35 /* AsteriskToken */: return left * right; + case 36 /* SlashToken */: return left / right; + case 33 /* PlusToken */: return left + right; + case 34 /* MinusToken */: return left - right; + case 37 /* PercentToken */: return left % right; } return undefined; - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: return +e.text; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return enumIsConst ? evalConstant(e.expression) : undefined; - case 63 /* Identifier */: - case 146 /* IndexedAccess */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 150 /* ElementAccessExpression */: + case 149 /* PropertyAccessExpression */: if (!enumIsConst) { return undefined; } @@ -16036,21 +17491,21 @@ var ts; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 63 /* Identifier */) { + if (e.kind === 64 /* Identifier */) { enumType = currentType; propertyName = e.text; } else { - if (e.kind === 146 /* IndexedAccess */) { - if (e.index.kind !== 7 /* StringLiteral */) { + if (e.kind === 150 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; } - var enumType = getTypeOfNode(e.object); - propertyName = e.index.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.argumentExpression.text; } else { - var enumType = getTypeOfNode(e.left); - propertyName = e.right.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.name.text; } if (enumType !== currentType) { return undefined; @@ -16085,7 +17540,7 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { var enumIsConst = ts.isConst(node); @@ -16097,7 +17552,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 191 /* EnumDeclaration */) { + if (declaration.kind !== 194 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -16120,7 +17575,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 191 /* ClassDeclaration */ || (declaration.kind === 190 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -16143,7 +17598,7 @@ var ts; } } } - if (node.name.kind === 7 /* StringLiteral */) { + if (node.name.kind === 8 /* StringLiteral */) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); } @@ -16165,34 +17620,39 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; - if (node.entityName) { + if (ts.isInternalModuleImportDeclaration(node)) { target = resolveImport(symbol); if (target !== unknownSymbol) { if (target.flags & 107455 /* Value */) { - var moduleName = getFirstIdentifier(node.entityName); + var moduleName = getFirstIdentifier(node.moduleReference); if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { - checkExpression(node.entityName); + checkExpressionOrQualifiedName(node.moduleReference); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 3152352 /* Type */) { + if (target.flags & 793056 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (node.parent.kind === 197 /* SourceFile */) { + if (node.parent.kind === 207 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { - if (isExternalModuleNameRelative(node.externalModuleName.text)) { - error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); - target = unknownSymbol; + else if (node.parent.kind === 196 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */) { + if (ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + if (isExternalModuleNameRelative(ts.getExternalModuleImportDeclarationExpression(node).text)) { + error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + target = unknownSymbol; + } + else { + target = resolveImport(symbol); + } } else { - target = resolveImport(symbol); + target = unknownSymbol; } } else { @@ -16200,7 +17660,7 @@ var ts; } } if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 3152352 /* Type */ ? 3152352 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { error(node, ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0, symbolToString(symbol)); } @@ -16208,7 +17668,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 197 /* SourceFile */) { + if (container.kind !== 207 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -16217,170 +17677,180 @@ var ts; if (!node) return; switch (node.kind) { - case 122 /* TypeParameter */: + case 123 /* TypeParameter */: return checkTypeParameter(node); - case 123 /* Parameter */: + case 124 /* Parameter */: return checkParameter(node); - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return checkPropertyDeclaration(node); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: return checkSignatureDeclaration(node); - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: return checkMethodDeclaration(node); - case 126 /* Constructor */: + case 129 /* Constructor */: return checkConstructorDeclaration(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return checkAccessorDeclaration(node); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return checkTypeReference(node); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return checkTypeQuery(node); - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: return checkTypeLiteral(node); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return checkArrayType(node); - case 138 /* TupleType */: + case 141 /* TupleType */: return checkTupleType(node); - case 139 /* UnionType */: + case 142 /* UnionType */: return checkUnionType(node); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return checkSourceElement(node.type); - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 162 /* Block */: + case 169 /* Block */: + case 196 /* ModuleBlock */: return checkBlock(node); - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - return checkBody(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return checkVariableStatement(node); - case 165 /* ExpressionStatement */: + case 172 /* ExpressionStatement */: return checkExpressionStatement(node); - case 166 /* IfStatement */: + case 173 /* IfStatement */: return checkIfStatement(node); - case 167 /* DoStatement */: + case 174 /* DoStatement */: return checkDoStatement(node); - case 168 /* WhileStatement */: + case 175 /* WhileStatement */: return checkWhileStatement(node); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return checkForStatement(node); - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return checkForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return checkReturnStatement(node); - case 174 /* WithStatement */: + case 181 /* WithStatement */: return checkWithStatement(node); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return checkSwitchStatement(node); - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return checkLabeledStatement(node); - case 179 /* ThrowStatement */: + case 184 /* ThrowStatement */: return checkThrowStatement(node); - case 180 /* TryStatement */: + case 185 /* TryStatement */: return checkTryStatement(node); - case 185 /* VariableDeclaration */: - return ts.Debug.fail("Checker encountered variable declaration"); - case 188 /* ClassDeclaration */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + return checkVariableLikeDeclaration(node); + case 191 /* ClassDeclaration */: return checkClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 193 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return checkImportDeclaration(node); - case 195 /* ExportAssignment */: + case 198 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); - checkFunctionExpressionBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + ts.forEach(node.parameters, checkFunctionExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 174 /* WithStatement */: + case 181 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 123 /* Parameter */: - case 124 /* Property */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 143 /* PropertyAssignment */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 197 /* SourceFile */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + case 146 /* BindingElement */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 204 /* PropertyAssignment */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 153 /* TaggedTemplateExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 159 /* TypeOfExpression */: + case 160 /* VoidExpression */: + case 158 /* DeleteExpression */: + case 161 /* PrefixUnaryExpression */: + case 162 /* PostfixUnaryExpression */: + case 163 /* BinaryExpression */: + case 164 /* ConditionalExpression */: + case 169 /* Block */: + case 196 /* ModuleBlock */: + case 170 /* VariableStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + case 180 /* ReturnStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + case 189 /* VariableDeclaration */: + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 206 /* EnumMember */: + case 207 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } } - function checkBody(node) { - checkBlock(node); - checkFunctionExpressionBodies(node); - } function checkSourceFile(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { emitExtends = false; potentialThisCollisions.length = 0; - checkBody(node); + ts.forEach(node.statements, checkSourceElement); + checkFunctionExpressionBodies(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); - if (symbol && symbol.flags & 33554432 /* Import */) { + if (symbol && symbol.flags & 8388608 /* Import */) { getSymbolLinks(symbol).referenced = true; } } @@ -16388,14 +17858,12 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) + if (emitExtends) { links.flags |= 8 /* EmitExtends */; + } links.flags |= 1 /* TypeChecked */; } } - function checkProgram() { - ts.forEach(program.getSourceFiles(), checkSourceFile); - } function getSortedDiagnostics() { ts.Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode"); if (diagnosticsModified) { @@ -16410,7 +17878,7 @@ var ts; checkSourceFile(sourceFile); return ts.filter(getSortedDiagnostics(), function (d) { return d.file === sourceFile; }); } - checkProgram(); + ts.forEach(program.getSourceFiles(), checkSourceFile); return getSortedDiagnostics(); } function getDeclarationDiagnostics(targetSourceFile) { @@ -16421,25 +17889,10 @@ var ts; function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } - function getNodeAtPosition(sourceFile, position) { - function findChildAtPosition(parent) { - var child = ts.forEachChild(parent, function (node) { - if (position >= node.pos && position <= node.end && position >= ts.getTokenPosOfNode(node)) { - return findChildAtPosition(node); - } - }); - return child || parent; - } - if (position < sourceFile.pos) - position = sourceFile.pos; - if (position > sourceFile.end) - position = sourceFile.end; - return findChildAtPosition(sourceFile); - } function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 181 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -16475,28 +17928,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); + case 195 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); + copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 152 /* FunctionExpression */: + case 156 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 182 /* CatchBlock */: - if (location.variable.text) { + case 203 /* CatchClause */: + if (location.name.text) { copySymbol(location.symbol, meaning); } break; @@ -16508,15 +17961,15 @@ var ts; return ts.mapToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 63 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; + return name.kind == 64 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 122 /* TypeParameter */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: + case 123 /* TypeParameter */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 194 /* EnumDeclaration */: return true; } } @@ -16524,60 +17977,62 @@ var ts; var node = entityName; while (node.parent && node.parent.kind === 121 /* QualifiedName */) node = node.parent; - return node.parent && node.parent.kind === 132 /* TypeReference */; + return node.parent && node.parent.kind === 135 /* TypeReference */; } function isTypeNode(node) { - if (132 /* FirstTypeNode */ <= node.kind && node.kind <= 140 /* LastTypeNode */) { + if (135 /* FirstTypeNode */ <= node.kind && node.kind <= 143 /* LastTypeNode */) { return true; } switch (node.kind) { - case 109 /* AnyKeyword */: - case 116 /* NumberKeyword */: - case 118 /* StringKeyword */: - case 110 /* BooleanKeyword */: + case 110 /* AnyKeyword */: + case 117 /* NumberKeyword */: + case 119 /* StringKeyword */: + case 111 /* BooleanKeyword */: return true; - case 97 /* VoidKeyword */: - return node.parent.kind !== 154 /* PrefixOperator */; - case 7 /* StringLiteral */: - return node.parent.kind === 123 /* Parameter */; - case 63 /* Identifier */: + case 98 /* VoidKeyword */: + return node.parent.kind !== 160 /* VoidExpression */; + case 8 /* StringLiteral */: + return node.parent.kind === 124 /* Parameter */; + case 64 /* Identifier */: if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } case 121 /* QualifiedName */: - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + ts.Debug.assert(node.kind === 64 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; - if (parent.kind === 135 /* TypeQuery */) { + if (parent.kind === 138 /* TypeQuery */) { return false; } - if (132 /* FirstTypeNode */ <= parent.kind && parent.kind <= 140 /* LastTypeNode */) { + if (135 /* FirstTypeNode */ <= parent.kind && parent.kind <= 143 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 122 /* TypeParameter */: + case 123 /* TypeParameter */: return node === parent.constraint; - case 124 /* Property */: - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: return node === parent.type; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 129 /* Constructor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node === parent.type; - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: return node === parent.type; - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return node === parent.type; - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; - case 149 /* TaggedTemplateExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 153 /* TaggedTemplateExpression */: return false; } } @@ -16587,49 +18042,58 @@ var ts; while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 194 /* ImportDeclaration */) { - return node.parent.entityName === node; + if (node.parent.kind === 197 /* ImportDeclaration */) { + return node.parent.moduleReference === node; } - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 198 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 145 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) || (node.parent.kind === 149 /* PropertyAccessExpression */ && node.parent.name === node); } - function getSymbolOfEntityName(entityName) { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 195 /* ExportAssignment */) { - return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); + if (entityName.parent.kind === 198 /* ExportAssignment */) { + return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Import */); } - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImport(entityName); + if (entityName.kind !== 149 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImport(entityName); + } } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (ts.isExpression(entityName)) { - if (entityName.kind === 63 /* Identifier */) { - var meaning = 107455 /* Value */ | 33554432 /* Import */; + if (ts.getFullWidth(entityName) === 0) { + return undefined; + } + if (entityName.kind === 64 /* Identifier */) { + var meaning = 107455 /* Value */ | 8388608 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 145 /* PropertyAccess */) { + else if (entityName.kind === 149 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { - checkPropertyAccess(entityName); + checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else { - return; + else if (entityName.kind === 121 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 132 /* TypeReference */ ? 3152352 /* Type */ : 1536 /* Namespace */; - meaning |= 33554432 /* Import */; + var meaning = entityName.parent.kind === 135 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + meaning |= 8388608 /* Import */; return resolveEntityName(entityName, entityName, meaning); } return undefined; @@ -16641,33 +18105,33 @@ var ts; if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + if (node.kind === 64 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 198 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { - case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 149 /* PropertyAccessExpression */: case 121 /* QualifiedName */: - return getSymbolOfEntityName(node); - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 111 /* ConstructorKeyword */: + case 112 /* ConstructorKeyword */: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 126 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 129 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 7 /* StringLiteral */: - if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) { - var importSymbol = getSymbolOfNode(node.parent); + case 8 /* StringLiteral */: + if (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node) { + var importSymbol = getSymbolOfNode(node.parent.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } - case 6 /* NumericLiteral */: - if (node.parent.kind == 146 /* IndexedAccess */ && node.parent.index === node) { - var objectType = checkExpression(node.parent.object); + case 7 /* NumericLiteral */: + if (node.parent.kind == 150 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); @@ -16680,7 +18144,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 144 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 205 /* ShorthandPropertyAssignment */) { return resolveEntityName(location, location.name, 107455 /* Value */); } return undefined; @@ -16737,7 +18201,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 1073741824 /* UnionProperty */) { + if (symbol.flags & 268435456 /* UnionProperty */) { var symbols = []; var name = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { @@ -16745,7 +18209,7 @@ var ts; }); return symbols; } - else if (symbol.flags & 268435456 /* Transient */) { + else if (symbol.flags & 67108864 /* Transient */) { var target = getSymbolLinks(symbol).target; if (target) { return [target]; @@ -16754,7 +18218,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 207 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -16766,7 +18230,7 @@ var ts; } function isUniqueLocalName(name, container) { for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 4194304 /* ExportValue */)) { + if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */)) { return false; } } @@ -16787,7 +18251,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 195 /* ModuleDeclaration */ || node.kind === 194 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -16811,13 +18275,13 @@ var ts; return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } function isTopLevelValueImportWithEntityName(node) { - if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) { + if (node.parent.kind !== 207 /* SourceFile */ || !ts.isInternalModuleImportDeclaration(node)) { return false; } return isImportResolvedToValue(getSymbolOfNode(node)); } - function hasSemanticErrors() { - return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; + function hasSemanticErrors(sourceFile) { + return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0; } function isEmitBlocked(sourceFile) { return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); @@ -16862,21 +18326,24 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 206 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } return undefined; } - function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getTypeOfSymbol(symbol) : unknownType; getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } + function isUnknownIdentifier(location, name) { + return !resolveName(location, name, 107455 /* Value */, undefined, undefined); + } function createResolver() { return { getProgram: function () { return program; }, @@ -16891,16 +18358,16 @@ var ts; isEmitBlocked: isEmitBlocked, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, - writeTypeAtLocation: writeTypeAtLocation, + writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue + getConstantValue: getConstantValue, + isUnknownIdentifier: isUnknownIdentifier }; } function invokeEmitter(targetSourceFile) { var resolver = createResolver(); - checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } function initializeTypeChecker() { @@ -16926,6 +18393,7 @@ var ts; globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTemplateStringsArrayType = compilerOptions.target >= 2 /* ES6 */ ? getGlobalType("TemplateStringsArray") : unknownType; + anyArrayType = createArrayType(anyType); } initializeTypeChecker(); return checker; @@ -17018,6 +18486,11 @@ var ts; 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: "removeComments", type: "boolean", @@ -17034,6 +18507,11 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + }, { name: "target", shortName: "t", @@ -17053,11 +18531,6 @@ var ts; shortName: "w", type: "boolean", description: ts.Diagnostics.Watch_input_files - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code } ]; var shortOptionNames = {}; @@ -17129,7 +18602,7 @@ var ts; } } function parseResponseFile(filename) { - var text = sys.readFile(filename); + var text = ts.sys.readFile(filename); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, filename)); return; @@ -17167,7 +18640,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var version = "1.3.0.0"; + var version = "1.4.0.0"; function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -17183,18 +18656,18 @@ var ts; return true; } function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); + var compilerFilePath = ts.normalizePath(ts.sys.getExecutingFilePath()); var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); var filePath = ts.combinePaths(containingDirectoryPath, language); if (territory) { filePath = filePath + "-" + territory; } - filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!sys.fileExists(filePath)) { + filePath = ts.sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!ts.sys.fileExists(filePath)) { return false; } try { - var fileContents = sys.readFile(filePath); + var fileContents = ts.sys.readFile(filePath); } catch (e) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); @@ -17231,8 +18704,8 @@ var ts; output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): "; } var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine; - sys.write(output); + output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + ts.sys.newLine; + ts.sys.write(output); } function reportDiagnostics(diagnostics) { for (var i = 0; i < diagnostics.length; i++) { @@ -17252,7 +18725,7 @@ var ts; return s; } function reportStatisticalValue(name, value) { - sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + sys.newLine); + ts.sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + ts.sys.newLine); } function reportCountStatistic(name, count) { reportStatisticalValue(name, "" + count); @@ -17260,101 +18733,45 @@ var ts; function reportTimeStatistic(name, time) { reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } - function createCompilerHost(options) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(filename, languageVersion, onError) { - try { - var text = sys.readFile(filename, options.charset); - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode ? getDiagnosticText(ts.Diagnostics.Unsupported_file_encoding) : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(filename, text, languageVersion, "0") : undefined; - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - sys.createDirectory(directoryPath); - } - } - try { - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - sys.writeFile(fileName, data, writeByteOrderMark); - } - catch (e) { - if (onError) - onError(e.message); - } - } - return { - getSourceFile: getSourceFile, - getDefaultLibFilename: function () { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(sys.getExecutingFilePath())), "lib.d.ts"); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return sys.newLine; } - }; - } function executeCommandLine(args) { var commandLine = ts.parseCommandLine(args); var compilerOptions = commandLine.options; if (compilerOptions.locale) { if (typeof JSON === "undefined") { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); - return sys.exit(1); + return ts.sys.exit(1); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } if (commandLine.errors.length > 0) { reportDiagnostics(commandLine.errors); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } if (compilerOptions.version) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, version)); - return sys.exit(0 /* Succeeded */); + return ts.sys.exit(0 /* Succeeded */); } if (compilerOptions.help) { printVersion(); printHelp(); - return sys.exit(0 /* Succeeded */); + return ts.sys.exit(0 /* Succeeded */); } if (commandLine.filenames.length === 0) { printVersion(); printHelp(); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } - var defaultCompilerHost = createCompilerHost(compilerOptions); + var defaultCompilerHost = ts.createCompilerHost(compilerOptions); if (compilerOptions.watch) { - if (!sys.watchFile) { + if (!ts.sys.watchFile) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } watchProgram(commandLine, defaultCompilerHost); } else { var result = compile(commandLine, defaultCompilerHost).exitStatus; - return sys.exit(result); + return ts.sys.exit(result); } } ts.executeCommandLine = executeCommandLine; @@ -17368,7 +18785,7 @@ var ts; function addWatchers(program) { ts.forEach(program.getSourceFiles(), function (f) { var filename = getCanonicalName(f.filename); - watchers[filename] = sys.watchFile(filename, fileUpdated); + watchers[filename] = ts.sys.watchFile(filename, fileUpdated); }); } function removeWatchers(program) { @@ -17443,7 +18860,7 @@ var ts; } reportDiagnostics(errors); if (commandLine.options.diagnostics) { - var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; + var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0); @@ -17462,7 +18879,7 @@ var ts; return { program: program, exitStatus: exitStatus }; } function printVersion() { - sys.write(getDiagnosticText(ts.Diagnostics.Version_0, version) + sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, version) + ts.sys.newLine); } function printHelp() { var output = ""; @@ -17472,13 +18889,13 @@ var ts; var syntax = makePadding(marginLength - syntaxLength); syntax += "tsc [" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + " ...]"; output += getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax); - output += sys.newLine + sys.newLine; + output += ts.sys.newLine + ts.sys.newLine; var padding = makePadding(marginLength); - output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; - output += padding + "tsc --out file.js file.ts" + sys.newLine; - output += padding + "tsc @args.txt" + sys.newLine; - output += sys.newLine; - output += getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine; + output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine; + output += padding + "tsc --out file.js file.ts" + ts.sys.newLine; + output += padding + "tsc @args.txt" + ts.sys.newLine; + output += ts.sys.newLine; + output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; var optsList = ts.optionDeclarations.slice(); optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); var marginLength = 0; @@ -17492,11 +18909,11 @@ var ts; var usageText = " "; if (option.shortName) { usageText += "-" + option.shortName; - usageText += getParamName(option); + usageText += getParamType(option); usageText += ", "; } usageText += "--" + option.name; - usageText += getParamName(option); + usageText += getParamType(option); usageColumn.push(usageText); descriptionColumn.push(getDiagnosticText(option.description)); marginLength = Math.max(usageText.length, marginLength); @@ -17508,13 +18925,13 @@ var ts; for (var i = 0; i < usageColumn.length; i++) { var usage = usageColumn[i]; var description = descriptionColumn[i]; - output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine; + output += usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine; } - sys.write(output); + ts.sys.write(output); return; - function getParamName(option) { - if (option.paramName !== undefined) { - return " " + getDiagnosticText(option.paramName); + function getParamType(option) { + if (option.paramType !== undefined) { + return " " + getDiagnosticText(option.paramType); } return ""; } @@ -17523,4 +18940,4 @@ var ts; } } })(ts || (ts = {})); -ts.executeCommandLine(sys.args); +ts.executeCommandLine(ts.sys.args); diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts new file mode 100644 index 00000000000..6df15a572a7 --- /dev/null +++ b/bin/typescript.d.ts @@ -0,0 +1,1878 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module "typescript" { + interface Map { + [index: string]: T; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + ConflictMarkerTrivia = 6, + NumericLiteral = 7, + StringLiteral = 8, + RegularExpressionLiteral = 9, + NoSubstitutionTemplateLiteral = 10, + TemplateHead = 11, + TemplateMiddle = 12, + TemplateTail = 13, + OpenBraceToken = 14, + CloseBraceToken = 15, + OpenParenToken = 16, + CloseParenToken = 17, + OpenBracketToken = 18, + CloseBracketToken = 19, + DotToken = 20, + DotDotDotToken = 21, + SemicolonToken = 22, + CommaToken = 23, + LessThanToken = 24, + GreaterThanToken = 25, + LessThanEqualsToken = 26, + GreaterThanEqualsToken = 27, + EqualsEqualsToken = 28, + ExclamationEqualsToken = 29, + EqualsEqualsEqualsToken = 30, + ExclamationEqualsEqualsToken = 31, + EqualsGreaterThanToken = 32, + PlusToken = 33, + MinusToken = 34, + AsteriskToken = 35, + SlashToken = 36, + PercentToken = 37, + PlusPlusToken = 38, + MinusMinusToken = 39, + LessThanLessThanToken = 40, + GreaterThanGreaterThanToken = 41, + GreaterThanGreaterThanGreaterThanToken = 42, + AmpersandToken = 43, + BarToken = 44, + CaretToken = 45, + ExclamationToken = 46, + TildeToken = 47, + AmpersandAmpersandToken = 48, + BarBarToken = 49, + QuestionToken = 50, + ColonToken = 51, + EqualsToken = 52, + PlusEqualsToken = 53, + MinusEqualsToken = 54, + AsteriskEqualsToken = 55, + SlashEqualsToken = 56, + PercentEqualsToken = 57, + LessThanLessThanEqualsToken = 58, + GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanGreaterThanEqualsToken = 60, + AmpersandEqualsToken = 61, + BarEqualsToken = 62, + CaretEqualsToken = 63, + Identifier = 64, + BreakKeyword = 65, + CaseKeyword = 66, + CatchKeyword = 67, + ClassKeyword = 68, + ConstKeyword = 69, + ContinueKeyword = 70, + DebuggerKeyword = 71, + DefaultKeyword = 72, + DeleteKeyword = 73, + DoKeyword = 74, + ElseKeyword = 75, + EnumKeyword = 76, + ExportKeyword = 77, + ExtendsKeyword = 78, + FalseKeyword = 79, + FinallyKeyword = 80, + ForKeyword = 81, + FunctionKeyword = 82, + IfKeyword = 83, + ImportKeyword = 84, + InKeyword = 85, + InstanceOfKeyword = 86, + NewKeyword = 87, + NullKeyword = 88, + ReturnKeyword = 89, + SuperKeyword = 90, + SwitchKeyword = 91, + ThisKeyword = 92, + ThrowKeyword = 93, + TrueKeyword = 94, + TryKeyword = 95, + TypeOfKeyword = 96, + VarKeyword = 97, + VoidKeyword = 98, + WhileKeyword = 99, + WithKeyword = 100, + ImplementsKeyword = 101, + InterfaceKeyword = 102, + LetKeyword = 103, + PackageKeyword = 104, + PrivateKeyword = 105, + ProtectedKeyword = 106, + PublicKeyword = 107, + StaticKeyword = 108, + YieldKeyword = 109, + AnyKeyword = 110, + BooleanKeyword = 111, + ConstructorKeyword = 112, + DeclareKeyword = 113, + GetKeyword = 114, + ModuleKeyword = 115, + RequireKeyword = 116, + NumberKeyword = 117, + SetKeyword = 118, + StringKeyword = 119, + TypeKeyword = 120, + QualifiedName = 121, + ComputedPropertyName = 122, + TypeParameter = 123, + Parameter = 124, + PropertySignature = 125, + PropertyDeclaration = 126, + MethodSignature = 127, + MethodDeclaration = 128, + Constructor = 129, + GetAccessor = 130, + SetAccessor = 131, + CallSignature = 132, + ConstructSignature = 133, + IndexSignature = 134, + TypeReference = 135, + FunctionType = 136, + ConstructorType = 137, + TypeQuery = 138, + TypeLiteral = 139, + ArrayType = 140, + TupleType = 141, + UnionType = 142, + ParenthesizedType = 143, + ObjectBindingPattern = 144, + ArrayBindingPattern = 145, + BindingElement = 146, + ArrayLiteralExpression = 147, + ObjectLiteralExpression = 148, + PropertyAccessExpression = 149, + ElementAccessExpression = 150, + CallExpression = 151, + NewExpression = 152, + TaggedTemplateExpression = 153, + TypeAssertionExpression = 154, + ParenthesizedExpression = 155, + FunctionExpression = 156, + ArrowFunction = 157, + DeleteExpression = 158, + TypeOfExpression = 159, + VoidExpression = 160, + PrefixUnaryExpression = 161, + PostfixUnaryExpression = 162, + BinaryExpression = 163, + ConditionalExpression = 164, + TemplateExpression = 165, + YieldExpression = 166, + OmittedExpression = 167, + TemplateSpan = 168, + Block = 169, + VariableStatement = 170, + EmptyStatement = 171, + ExpressionStatement = 172, + IfStatement = 173, + DoStatement = 174, + WhileStatement = 175, + ForStatement = 176, + ForInStatement = 177, + ContinueStatement = 178, + BreakStatement = 179, + ReturnStatement = 180, + WithStatement = 181, + SwitchStatement = 182, + LabeledStatement = 183, + ThrowStatement = 184, + TryStatement = 185, + TryBlock = 186, + FinallyBlock = 187, + DebuggerStatement = 188, + VariableDeclaration = 189, + FunctionDeclaration = 190, + ClassDeclaration = 191, + InterfaceDeclaration = 192, + TypeAliasDeclaration = 193, + EnumDeclaration = 194, + ModuleDeclaration = 195, + ModuleBlock = 196, + ImportDeclaration = 197, + ExportAssignment = 198, + ExternalModuleReference = 199, + CaseClause = 200, + DefaultClause = 201, + HeritageClause = 202, + CatchClause = 203, + PropertyAssignment = 204, + ShorthandPropertyAssignment = 205, + EnumMember = 206, + SourceFile = 207, + Program = 208, + SyntaxList = 209, + Count = 210, + FirstAssignment = 52, + LastAssignment = 63, + FirstReservedWord = 65, + LastReservedWord = 100, + FirstKeyword = 65, + LastKeyword = 120, + FirstFutureReservedWord = 101, + LastFutureReservedWord = 109, + FirstTypeNode = 135, + LastTypeNode = 143, + FirstPunctuation = 14, + LastPunctuation = 63, + FirstToken = 0, + LastToken = 120, + FirstTriviaToken = 2, + LastTriviaToken = 6, + FirstLiteralToken = 7, + LastLiteralToken = 10, + FirstTemplateToken = 10, + LastTemplateToken = 13, + FirstOperator = 22, + LastOperator = 63, + FirstBinaryOperator = 24, + LastBinaryOperator = 63, + FirstNode = 121, + } + const enum NodeFlags { + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + MultiLine = 256, + Synthetic = 512, + DeclarationFile = 1024, + Let = 2048, + Const = 4096, + OctalLiteral = 8192, + Modifier = 243, + AccessibilityModifier = 112, + BlockScoped = 6144, + } + const enum ParserContextFlags { + StrictMode = 1, + DisallowIn = 2, + Yield = 4, + GeneratorParameter = 8, + ThisNodeHasError = 16, + ParserGeneratedFlags = 31, + ThisNodeOrAnySubNodesHasError = 32, + HasComputedThisNodeOrAnySubNodesHasError = 64, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + parserContextFlags?: ParserContextFlags; + id?: number; + parent?: Node; + symbol?: Symbol; + locals?: SymbolTable; + nextContainer?: Node; + localSymbol?: Symbol; + modifiers?: ModifiersArray; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + name: Identifier | BindingPattern; + type?: TypeNode; + initializer?: Expression; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingElement extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + } + interface VariableLikeDeclaration extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingPattern extends Node { + elements: NodeArray; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * FunctionDeclaration + * MethodDeclaration + * AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionTypeNode extends TypeNode { + types: NodeArray; + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface StringLiteralTypeNode extends LiteralExpression, TypeNode { + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface PrefixUnaryExpression extends UnaryExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends PostfixExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends PostfixExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operator: SyntaxKind; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + whenTrue: Expression; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + } + interface StringLiteralExpression extends LiteralExpression { + _stringLiteralExpressionBrand: any; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + interface Statement extends Node, ModuleElement { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarations: NodeArray; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + declarations?: NodeArray; + initializer?: Expression; + condition?: Expression; + iterator?: Expression; + } + interface ForInStatement extends IterationStatement { + declarations?: NodeArray; + variable?: Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Declaration { + name: Identifier; + type?: TypeNode; + block: Block; + } + interface ModuleElement extends Node { + _moduleElementBrand: any; + } + interface ClassDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, ModuleElement { + name: Identifier; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, ModuleElement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, ModuleElement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, ModuleElement { + statements: NodeArray; + } + interface ImportDeclaration extends Declaration, ModuleElement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ExportAssignment extends Statement, ModuleElement { + exportName: Identifier; + } + interface FileReference extends TextRange { + filename: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + filename: string; + text: string; + getLineAndCharacterFromPosition(position: number): LineAndCharacter; + getPositionFromLineAndCharacter(line: number, character: number): number; + getLineStarts(): number[]; + amdDependencies: string[]; + amdModuleName: string; + referencedFiles: FileReference[]; + referenceDiagnostics: Diagnostic[]; + parseDiagnostics: Diagnostic[]; + grammarDiagnostics: Diagnostic[]; + getSyntacticDiagnostics(): Diagnostic[]; + semanticDiagnostics: Diagnostic[]; + hasNoDefaultLib: boolean; + externalModuleIndicator: Node; + nodeCount: number; + identifierCount: number; + symbolCount: number; + languageVersion: ScriptTarget; + identifiers: Map; + } + interface Program { + getSourceFile(filename: string): SourceFile; + getSourceFiles(): SourceFile[]; + getCompilerOptions(): CompilerOptions; + getCompilerHost(): CompilerHost; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getTypeChecker(fullTypeCheckMode: boolean): TypeChecker; + getCommonSourceDirectory(): string; + } + interface SourceMapSpan { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + nameIndex?: number; + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + enum EmitReturnStatus { + Succeeded = 0, + AllOutputGenerationSkipped = 1, + JSGeneratedWithSemanticErrors = 2, + DeclarationGenerationSkipped = 3, + EmitErrorsEncountered = 4, + CompilerOptionsErrors = 5, + } + interface EmitResult { + emitResultStatus: EmitReturnStatus; + diagnostics: Diagnostic[]; + sourceMaps: SourceMapData[]; + } + interface TypeChecker { + getProgram(): Program; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + emitFiles(targetSourceFile?: SourceFile): EmitResult; + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + 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; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getEnumMemberValue(node: EnumMember): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + } + 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): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + const enum SymbolAccessibility { + Accessible = 0, + NotAccessible = 1, + CannotBeNamed = 2, + } + interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: ImportDeclaration[]; + errorSymbolName?: string; + errorNode?: Node; + } + interface SymbolAccessiblityResult extends SymbolVisibilityResult { + errorModuleName?: string; + } + interface EmitResolver { + getProgram(): Program; + getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string; + getExpressionNamePrefix(node: Identifier): string; + getExportAssignmentName(node: SourceFile): string; + isReferencedImportDeclaration(node: ImportDeclaration): boolean; + isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean; + getNodeCheckFlags(node: Node): NodeCheckFlags; + getEnumMemberValue(node: EnumMember): number; + hasSemanticErrors(sourceFile?: SourceFile): boolean; + isDeclarationVisible(node: Declaration): boolean; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; + isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + isEmitBlocked(sourceFile?: SourceFile): boolean; + isUnknownIdentifier(location: Node, name: string): boolean; + } + const enum SymbolFlags { + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + Signature = 131072, + TypeParameter = 262144, + TypeAlias = 524288, + ExportValue = 1048576, + ExportType = 2097152, + ExportNamespace = 4194304, + Import = 8388608, + Instantiated = 16777216, + Merged = 33554432, + Transient = 67108864, + Prototype = 134217728, + UnionProperty = 268435456, + Optional = 536870912, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 793056, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 899583, + InterfaceExcludes = 792992, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 530912, + TypeAliasExcludes = 793056, + ImportExcludes = 8388608, + ModuleMember = 8914931, + ExportHasLocal = 944, + HasLocals = 255504, + HasExports = 1952, + HasMembers = 6240, + IsContainer = 262128, + PropertyOrAccessor = 98308, + Export = 7340032, + } + interface Symbol { + flags: SymbolFlags; + name: string; + id?: number; + mergeId?: number; + declarations?: Declaration[]; + parent?: Symbol; + members?: SymbolTable; + exports?: SymbolTable; + exportSymbol?: Symbol; + valueDeclaration?: Declaration; + constEnumOnlyModule?: boolean; + } + interface SymbolLinks { + target?: Symbol; + type?: Type; + declaredType?: Type; + mapper?: TypeMapper; + referenced?: boolean; + exportAssignSymbol?: Symbol; + unionType?: UnionType; + } + interface TransientSymbol extends Symbol, SymbolLinks { + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum NodeCheckFlags { + TypeChecked = 1, + LexicalThis = 2, + CaptureThis = 4, + EmitExtends = 8, + SuperInstance = 16, + SuperStatic = 32, + ContextChecked = 64, + EnumValuesComputed = 128, + } + interface NodeLinks { + resolvedType?: Type; + resolvedSignature?: Signature; + resolvedSymbol?: Symbol; + flags?: NodeCheckFlags; + enumMemberValue?: number; + isIllegalTypeReferenceInConstraint?: boolean; + isVisible?: boolean; + localModuleName?: string; + assignmentChecks?: Map; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Anonymous = 32768, + FromSignature = 65536, + Unwidened = 131072, + Intrinsic = 127, + StringLike = 258, + NumberLike = 132, + ObjectType = 48128, + } + interface Type { + flags: TypeFlags; + id: number; + symbol?: Symbol; + } + interface IntrinsicType extends Type { + intrinsicName: string; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + baseTypes: ObjectType[]; + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + instantiations: Map; + openReferenceTargets: GenericType[]; + openReferenceChecks: Map; + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + baseArrayType: TypeReference; + } + interface UnionType extends Type { + types: Type[]; + resolvedProperties: SymbolTable; + } + interface ResolvedType extends ObjectType, UnionType { + members: SymbolTable; + properties: Symbol[]; + callSignatures: Signature[]; + constructSignatures: Signature[]; + stringIndexType: Type; + numberIndexType: Type; + } + interface TypeParameter extends Type { + constraint: Type; + target?: TypeParameter; + mapper?: TypeMapper; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + resolvedReturnType: Type; + minArgumentCount: number; + hasRestParameter: boolean; + hasStringLiterals: boolean; + target?: Signature; + mapper?: TypeMapper; + unionSignatures?: Signature[]; + erasedSignatureCache?: Signature; + isolatedSignatureType?: ObjectType; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface TypeMapper { + (t: Type): Type; + } + interface TypeInferences { + primary: Type[]; + secondary: Type[]; + } + interface InferenceContext { + typeParameters: TypeParameter[]; + inferUnionTypes: boolean; + inferences: TypeInferences[]; + inferredTypes: Type[]; + failedTypeParameterIndex?: number; + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + isEarly?: boolean; + } + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string; + category: DiagnosticCategory; + code: number; + /** + * Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit + */ + isEarly?: boolean; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + codepage?: number; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noLibCheck?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + preserveConstEnums?: boolean; + removeComments?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + Latest = 2, + } + interface ParsedCommandLine { + options: CompilerOptions; + filenames: string[]; + errors: Diagnostic[]; + } + interface CommandLineOption { + name: string; + type: string | Map; + shortName?: string; + description?: DiagnosticMessage; + paramType?: DiagnosticMessage; + error?: DiagnosticMessage; + } + const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 127, + lineFeed = 10, + carriageReturn = 13, + lineSeparator = 8232, + paragraphSeparator = 8233, + nextLine = 133, + space = 32, + nonBreakingSpace = 160, + enQuad = 8192, + emQuad = 8193, + enSpace = 8194, + emSpace = 8195, + threePerEmSpace = 8196, + fourPerEmSpace = 8197, + sixPerEmSpace = 8198, + figureSpace = 8199, + punctuationSpace = 8200, + thinSpace = 8201, + hairSpace = 8202, + zeroWidthSpace = 8203, + narrowNoBreakSpace = 8239, + ideographicSpace = 12288, + mathematicalSpace = 8287, + ogham = 5760, + _ = 95, + $ = 36, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + ampersand = 38, + asterisk = 42, + at = 64, + backslash = 92, + backtick = 96, + bar = 124, + caret = 94, + closeBrace = 125, + closeBracket = 93, + closeParen = 41, + colon = 58, + comma = 44, + dot = 46, + doubleQuote = 34, + equals = 61, + exclamation = 33, + greaterThan = 62, + lessThan = 60, + minus = 45, + openBrace = 123, + openBracket = 91, + openParen = 40, + percent = 37, + plus = 43, + question = 63, + semicolon = 59, + singleQuote = 39, + slash = 47, + tilde = 126, + backspace = 8, + formFeed = 12, + byteOrderMark = 65279, + tab = 9, + verticalTab = 11, + } + interface CancellationToken { + isCancellationRequested(): boolean; + } + interface CompilerHost { + getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getDefaultLibFilename(options: CompilerOptions): string; + getCancellationToken?(): CancellationToken; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + } +} +declare module "typescript" { + interface ErrorCallback { + (message: DiagnosticMessage): void; + } + interface CommentCallback { + (pos: number, end: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function computeLineStarts(text: string): number[]; + function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number; + function getLineAndCharacterOfPosition(lineStarts: number[], position: number): { + line: number; + character: number; + }; + function positionToLineAndCharacter(text: string, pos: number): { + line: number; + character: number; + }; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function isOctalDigit(ch: number): boolean; + function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner; +} +declare module "typescript" { + function getNodeConstructor(kind: SyntaxKind): new () => Node; + function createNode(kind: SyntaxKind): Node; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function createCompilerHost(options: CompilerOptions): CompilerHost; + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; + function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; +} +declare module "typescript" { + function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker; +} +declare module "typescript" { + var servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + isOpen: boolean; + version: string; + getScriptSnapshot(): IScriptSnapshot; + getNamedDeclarations(): Declaration[]; + update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + } + /** + * 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 + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * This call returns the array containing the start position of every line. + * i.e."[0, 10, 55]". TODO: consider making this optional. The language service could + * always determine this (albeit in a more expensive manner). + */ + getLineStartPositions(): number[]; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + isLibFile: boolean; + } + interface Logger { + log(s: string): void; + trace(s: string): void; + error(s: string): void; + } + interface LanguageServiceHost extends Logger { + getCompilationSettings(): CompilerOptions; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptIsOpen(fileName: string): boolean; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): CancellationToken; + getCurrentDirectory(): string; + getDefaultLibFilename(options: CompilerOptions): string; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + getOutliningSpans(fileName: string): OutliningSpan[]; + getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getEmitOutput(fileName: string): EmitOutput; + getSourceFile(filename: string): SourceFile; + dispose(): void; + } + class TextSpan { + private _start; + private _length; + /** + * Creates a TextSpan instance beginning with the position Start and having the Length + * specified with length. + */ + constructor(start: number, length: number); + toJSON(key: any): any; + start(): number; + length(): number; + end(): number; + isEmpty(): boolean; + /** + * Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less + * than End, otherwise false. + * @param position The position to check. + */ + containsPosition(position: number): boolean; + /** + * Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false. + * @param span The span to check. + */ + containsTextSpan(span: TextSpan): boolean; + /** + * Determines whether the given span overlaps this span. Two spans are considered to overlap + * if they have positions in common and neither is empty. Empty spans do not overlap with any + * other span. Returns true if the spans overlap, false otherwise. + * @param span The span to check. + */ + overlapsWith(span: TextSpan): boolean; + /** + * Returns the overlap with the given span, or undefined if there is no overlap. + * @param span The span to check. + */ + overlap(span: TextSpan): TextSpan; + /** + * Determines whether span intersects this span. Two spans are considered to + * intersect if they have positions in common or the end of one span + * coincides with the start of the other span. Returns true if the spans intersect, false otherwise. + * @param The span to check. + */ + intersectsWithTextSpan(span: TextSpan): boolean; + intersectsWith(start: number, length: number): boolean; + /** + * Determines whether the given position intersects this span. + * A position is considered to intersect if it is between the start and + * end positions (inclusive) of this span. Returns true if the position intersects, false otherwise. + * @param position The position to check. + */ + intersectsWithPosition(position: number): boolean; + /** + * Returns the intersection with the given span, or undefined if there is no intersection. + * @param span The span to check. + */ + intersection(span: TextSpan): TextSpan; + /** + * Creates a new TextSpan from the given start and end positions + * as opposed to a position and length. + */ + static fromBounds(start: number, end: number): TextSpan; + } + class TextChangeRange { + static unchanged: TextChangeRange; + private _span; + private _newLength; + /** + * Initializes a new instance of TextChangeRange. + */ + constructor(span: TextSpan, newLength: number); + /** + * The span of text before the edit which is being changed + */ + span(): TextSpan; + /** + * Width of the span after the edit. A 0 here would represent a delete + */ + newLength(): number; + newSpan(): TextSpan; + isUnchanged(): boolean; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** 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. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitOutputStatus: EmitReturnStatus; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + Start = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult; + } + interface DocumentRegistry { + acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean): SourceFile; + updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + releaseDocument(filename: string, compilationSettings: CompilerOptions): void; + } + class ScriptElementKind { + static unknown: string; + static keyword: string; + static scriptElement: string; + static moduleElement: string; + static classElement: string; + static interfaceElement: string; + static typeElement: string; + static enumElement: string; + static variableElement: string; + static localVariableElement: string; + static functionElement: string; + static localFunctionElement: string; + static memberFunctionElement: string; + static memberGetAccessorElement: string; + static memberSetAccessorElement: string; + static memberVariableElement: string; + static constructorImplementationElement: string; + static callSignatureElement: string; + static indexSignatureElement: string; + static constructSignatureElement: string; + static parameterElement: string; + static typeParameterElement: string; + static primitiveType: string; + static label: string; + static alias: string; + static constElement: string; + static letElement: string; + } + class ScriptElementKindModifier { + static none: string; + static publicMemberModifier: string; + static privateMemberModifier: string; + static protectedMemberModifier: string; + static exportedModifier: string; + static ambientModifier: string; + static staticModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAlias: string; + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + class OperationCanceledException { + } + class CancellationTokenObject { + private cancellationToken; + static None: CancellationTokenObject; + constructor(cancellationToken: CancellationToken); + isCancellationRequested(): boolean; + throwIfCancellationRequested(): void; + } + function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile; + function createDocumentRegistry(): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService; + function createClassifier(host: Logger): Classifier; +} diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts new file mode 100644 index 00000000000..2fd17ddf8b4 --- /dev/null +++ b/bin/typescriptServices.d.ts @@ -0,0 +1,1878 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module ts { + interface Map { + [index: string]: T; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + ConflictMarkerTrivia = 6, + NumericLiteral = 7, + StringLiteral = 8, + RegularExpressionLiteral = 9, + NoSubstitutionTemplateLiteral = 10, + TemplateHead = 11, + TemplateMiddle = 12, + TemplateTail = 13, + OpenBraceToken = 14, + CloseBraceToken = 15, + OpenParenToken = 16, + CloseParenToken = 17, + OpenBracketToken = 18, + CloseBracketToken = 19, + DotToken = 20, + DotDotDotToken = 21, + SemicolonToken = 22, + CommaToken = 23, + LessThanToken = 24, + GreaterThanToken = 25, + LessThanEqualsToken = 26, + GreaterThanEqualsToken = 27, + EqualsEqualsToken = 28, + ExclamationEqualsToken = 29, + EqualsEqualsEqualsToken = 30, + ExclamationEqualsEqualsToken = 31, + EqualsGreaterThanToken = 32, + PlusToken = 33, + MinusToken = 34, + AsteriskToken = 35, + SlashToken = 36, + PercentToken = 37, + PlusPlusToken = 38, + MinusMinusToken = 39, + LessThanLessThanToken = 40, + GreaterThanGreaterThanToken = 41, + GreaterThanGreaterThanGreaterThanToken = 42, + AmpersandToken = 43, + BarToken = 44, + CaretToken = 45, + ExclamationToken = 46, + TildeToken = 47, + AmpersandAmpersandToken = 48, + BarBarToken = 49, + QuestionToken = 50, + ColonToken = 51, + EqualsToken = 52, + PlusEqualsToken = 53, + MinusEqualsToken = 54, + AsteriskEqualsToken = 55, + SlashEqualsToken = 56, + PercentEqualsToken = 57, + LessThanLessThanEqualsToken = 58, + GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanGreaterThanEqualsToken = 60, + AmpersandEqualsToken = 61, + BarEqualsToken = 62, + CaretEqualsToken = 63, + Identifier = 64, + BreakKeyword = 65, + CaseKeyword = 66, + CatchKeyword = 67, + ClassKeyword = 68, + ConstKeyword = 69, + ContinueKeyword = 70, + DebuggerKeyword = 71, + DefaultKeyword = 72, + DeleteKeyword = 73, + DoKeyword = 74, + ElseKeyword = 75, + EnumKeyword = 76, + ExportKeyword = 77, + ExtendsKeyword = 78, + FalseKeyword = 79, + FinallyKeyword = 80, + ForKeyword = 81, + FunctionKeyword = 82, + IfKeyword = 83, + ImportKeyword = 84, + InKeyword = 85, + InstanceOfKeyword = 86, + NewKeyword = 87, + NullKeyword = 88, + ReturnKeyword = 89, + SuperKeyword = 90, + SwitchKeyword = 91, + ThisKeyword = 92, + ThrowKeyword = 93, + TrueKeyword = 94, + TryKeyword = 95, + TypeOfKeyword = 96, + VarKeyword = 97, + VoidKeyword = 98, + WhileKeyword = 99, + WithKeyword = 100, + ImplementsKeyword = 101, + InterfaceKeyword = 102, + LetKeyword = 103, + PackageKeyword = 104, + PrivateKeyword = 105, + ProtectedKeyword = 106, + PublicKeyword = 107, + StaticKeyword = 108, + YieldKeyword = 109, + AnyKeyword = 110, + BooleanKeyword = 111, + ConstructorKeyword = 112, + DeclareKeyword = 113, + GetKeyword = 114, + ModuleKeyword = 115, + RequireKeyword = 116, + NumberKeyword = 117, + SetKeyword = 118, + StringKeyword = 119, + TypeKeyword = 120, + QualifiedName = 121, + ComputedPropertyName = 122, + TypeParameter = 123, + Parameter = 124, + PropertySignature = 125, + PropertyDeclaration = 126, + MethodSignature = 127, + MethodDeclaration = 128, + Constructor = 129, + GetAccessor = 130, + SetAccessor = 131, + CallSignature = 132, + ConstructSignature = 133, + IndexSignature = 134, + TypeReference = 135, + FunctionType = 136, + ConstructorType = 137, + TypeQuery = 138, + TypeLiteral = 139, + ArrayType = 140, + TupleType = 141, + UnionType = 142, + ParenthesizedType = 143, + ObjectBindingPattern = 144, + ArrayBindingPattern = 145, + BindingElement = 146, + ArrayLiteralExpression = 147, + ObjectLiteralExpression = 148, + PropertyAccessExpression = 149, + ElementAccessExpression = 150, + CallExpression = 151, + NewExpression = 152, + TaggedTemplateExpression = 153, + TypeAssertionExpression = 154, + ParenthesizedExpression = 155, + FunctionExpression = 156, + ArrowFunction = 157, + DeleteExpression = 158, + TypeOfExpression = 159, + VoidExpression = 160, + PrefixUnaryExpression = 161, + PostfixUnaryExpression = 162, + BinaryExpression = 163, + ConditionalExpression = 164, + TemplateExpression = 165, + YieldExpression = 166, + OmittedExpression = 167, + TemplateSpan = 168, + Block = 169, + VariableStatement = 170, + EmptyStatement = 171, + ExpressionStatement = 172, + IfStatement = 173, + DoStatement = 174, + WhileStatement = 175, + ForStatement = 176, + ForInStatement = 177, + ContinueStatement = 178, + BreakStatement = 179, + ReturnStatement = 180, + WithStatement = 181, + SwitchStatement = 182, + LabeledStatement = 183, + ThrowStatement = 184, + TryStatement = 185, + TryBlock = 186, + FinallyBlock = 187, + DebuggerStatement = 188, + VariableDeclaration = 189, + FunctionDeclaration = 190, + ClassDeclaration = 191, + InterfaceDeclaration = 192, + TypeAliasDeclaration = 193, + EnumDeclaration = 194, + ModuleDeclaration = 195, + ModuleBlock = 196, + ImportDeclaration = 197, + ExportAssignment = 198, + ExternalModuleReference = 199, + CaseClause = 200, + DefaultClause = 201, + HeritageClause = 202, + CatchClause = 203, + PropertyAssignment = 204, + ShorthandPropertyAssignment = 205, + EnumMember = 206, + SourceFile = 207, + Program = 208, + SyntaxList = 209, + Count = 210, + FirstAssignment = 52, + LastAssignment = 63, + FirstReservedWord = 65, + LastReservedWord = 100, + FirstKeyword = 65, + LastKeyword = 120, + FirstFutureReservedWord = 101, + LastFutureReservedWord = 109, + FirstTypeNode = 135, + LastTypeNode = 143, + FirstPunctuation = 14, + LastPunctuation = 63, + FirstToken = 0, + LastToken = 120, + FirstTriviaToken = 2, + LastTriviaToken = 6, + FirstLiteralToken = 7, + LastLiteralToken = 10, + FirstTemplateToken = 10, + LastTemplateToken = 13, + FirstOperator = 22, + LastOperator = 63, + FirstBinaryOperator = 24, + LastBinaryOperator = 63, + FirstNode = 121, + } + const enum NodeFlags { + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + MultiLine = 256, + Synthetic = 512, + DeclarationFile = 1024, + Let = 2048, + Const = 4096, + OctalLiteral = 8192, + Modifier = 243, + AccessibilityModifier = 112, + BlockScoped = 6144, + } + const enum ParserContextFlags { + StrictMode = 1, + DisallowIn = 2, + Yield = 4, + GeneratorParameter = 8, + ThisNodeHasError = 16, + ParserGeneratedFlags = 31, + ThisNodeOrAnySubNodesHasError = 32, + HasComputedThisNodeOrAnySubNodesHasError = 64, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + parserContextFlags?: ParserContextFlags; + id?: number; + parent?: Node; + symbol?: Symbol; + locals?: SymbolTable; + nextContainer?: Node; + localSymbol?: Symbol; + modifiers?: ModifiersArray; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + name: Identifier | BindingPattern; + type?: TypeNode; + initializer?: Expression; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingElement extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + } + interface VariableLikeDeclaration extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingPattern extends Node { + elements: NodeArray; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * FunctionDeclaration + * MethodDeclaration + * AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionTypeNode extends TypeNode { + types: NodeArray; + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface StringLiteralTypeNode extends LiteralExpression, TypeNode { + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface PrefixUnaryExpression extends UnaryExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends PostfixExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends PostfixExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operator: SyntaxKind; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + whenTrue: Expression; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + } + interface StringLiteralExpression extends LiteralExpression { + _stringLiteralExpressionBrand: any; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + interface Statement extends Node, ModuleElement { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarations: NodeArray; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + declarations?: NodeArray; + initializer?: Expression; + condition?: Expression; + iterator?: Expression; + } + interface ForInStatement extends IterationStatement { + declarations?: NodeArray; + variable?: Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Declaration { + name: Identifier; + type?: TypeNode; + block: Block; + } + interface ModuleElement extends Node { + _moduleElementBrand: any; + } + interface ClassDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, ModuleElement { + name: Identifier; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, ModuleElement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, ModuleElement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, ModuleElement { + statements: NodeArray; + } + interface ImportDeclaration extends Declaration, ModuleElement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ExportAssignment extends Statement, ModuleElement { + exportName: Identifier; + } + interface FileReference extends TextRange { + filename: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + filename: string; + text: string; + getLineAndCharacterFromPosition(position: number): LineAndCharacter; + getPositionFromLineAndCharacter(line: number, character: number): number; + getLineStarts(): number[]; + amdDependencies: string[]; + amdModuleName: string; + referencedFiles: FileReference[]; + referenceDiagnostics: Diagnostic[]; + parseDiagnostics: Diagnostic[]; + grammarDiagnostics: Diagnostic[]; + getSyntacticDiagnostics(): Diagnostic[]; + semanticDiagnostics: Diagnostic[]; + hasNoDefaultLib: boolean; + externalModuleIndicator: Node; + nodeCount: number; + identifierCount: number; + symbolCount: number; + languageVersion: ScriptTarget; + identifiers: Map; + } + interface Program { + getSourceFile(filename: string): SourceFile; + getSourceFiles(): SourceFile[]; + getCompilerOptions(): CompilerOptions; + getCompilerHost(): CompilerHost; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getTypeChecker(fullTypeCheckMode: boolean): TypeChecker; + getCommonSourceDirectory(): string; + } + interface SourceMapSpan { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + nameIndex?: number; + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + enum EmitReturnStatus { + Succeeded = 0, + AllOutputGenerationSkipped = 1, + JSGeneratedWithSemanticErrors = 2, + DeclarationGenerationSkipped = 3, + EmitErrorsEncountered = 4, + CompilerOptionsErrors = 5, + } + interface EmitResult { + emitResultStatus: EmitReturnStatus; + diagnostics: Diagnostic[]; + sourceMaps: SourceMapData[]; + } + interface TypeChecker { + getProgram(): Program; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + emitFiles(targetSourceFile?: SourceFile): EmitResult; + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + 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; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getEnumMemberValue(node: EnumMember): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + } + 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): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + const enum SymbolAccessibility { + Accessible = 0, + NotAccessible = 1, + CannotBeNamed = 2, + } + interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: ImportDeclaration[]; + errorSymbolName?: string; + errorNode?: Node; + } + interface SymbolAccessiblityResult extends SymbolVisibilityResult { + errorModuleName?: string; + } + interface EmitResolver { + getProgram(): Program; + getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string; + getExpressionNamePrefix(node: Identifier): string; + getExportAssignmentName(node: SourceFile): string; + isReferencedImportDeclaration(node: ImportDeclaration): boolean; + isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean; + getNodeCheckFlags(node: Node): NodeCheckFlags; + getEnumMemberValue(node: EnumMember): number; + hasSemanticErrors(sourceFile?: SourceFile): boolean; + isDeclarationVisible(node: Declaration): boolean; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; + isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + isEmitBlocked(sourceFile?: SourceFile): boolean; + isUnknownIdentifier(location: Node, name: string): boolean; + } + const enum SymbolFlags { + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + Signature = 131072, + TypeParameter = 262144, + TypeAlias = 524288, + ExportValue = 1048576, + ExportType = 2097152, + ExportNamespace = 4194304, + Import = 8388608, + Instantiated = 16777216, + Merged = 33554432, + Transient = 67108864, + Prototype = 134217728, + UnionProperty = 268435456, + Optional = 536870912, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 793056, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 899583, + InterfaceExcludes = 792992, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 530912, + TypeAliasExcludes = 793056, + ImportExcludes = 8388608, + ModuleMember = 8914931, + ExportHasLocal = 944, + HasLocals = 255504, + HasExports = 1952, + HasMembers = 6240, + IsContainer = 262128, + PropertyOrAccessor = 98308, + Export = 7340032, + } + interface Symbol { + flags: SymbolFlags; + name: string; + id?: number; + mergeId?: number; + declarations?: Declaration[]; + parent?: Symbol; + members?: SymbolTable; + exports?: SymbolTable; + exportSymbol?: Symbol; + valueDeclaration?: Declaration; + constEnumOnlyModule?: boolean; + } + interface SymbolLinks { + target?: Symbol; + type?: Type; + declaredType?: Type; + mapper?: TypeMapper; + referenced?: boolean; + exportAssignSymbol?: Symbol; + unionType?: UnionType; + } + interface TransientSymbol extends Symbol, SymbolLinks { + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum NodeCheckFlags { + TypeChecked = 1, + LexicalThis = 2, + CaptureThis = 4, + EmitExtends = 8, + SuperInstance = 16, + SuperStatic = 32, + ContextChecked = 64, + EnumValuesComputed = 128, + } + interface NodeLinks { + resolvedType?: Type; + resolvedSignature?: Signature; + resolvedSymbol?: Symbol; + flags?: NodeCheckFlags; + enumMemberValue?: number; + isIllegalTypeReferenceInConstraint?: boolean; + isVisible?: boolean; + localModuleName?: string; + assignmentChecks?: Map; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Anonymous = 32768, + FromSignature = 65536, + Unwidened = 131072, + Intrinsic = 127, + StringLike = 258, + NumberLike = 132, + ObjectType = 48128, + } + interface Type { + flags: TypeFlags; + id: number; + symbol?: Symbol; + } + interface IntrinsicType extends Type { + intrinsicName: string; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + baseTypes: ObjectType[]; + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + instantiations: Map; + openReferenceTargets: GenericType[]; + openReferenceChecks: Map; + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + baseArrayType: TypeReference; + } + interface UnionType extends Type { + types: Type[]; + resolvedProperties: SymbolTable; + } + interface ResolvedType extends ObjectType, UnionType { + members: SymbolTable; + properties: Symbol[]; + callSignatures: Signature[]; + constructSignatures: Signature[]; + stringIndexType: Type; + numberIndexType: Type; + } + interface TypeParameter extends Type { + constraint: Type; + target?: TypeParameter; + mapper?: TypeMapper; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + resolvedReturnType: Type; + minArgumentCount: number; + hasRestParameter: boolean; + hasStringLiterals: boolean; + target?: Signature; + mapper?: TypeMapper; + unionSignatures?: Signature[]; + erasedSignatureCache?: Signature; + isolatedSignatureType?: ObjectType; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface TypeMapper { + (t: Type): Type; + } + interface TypeInferences { + primary: Type[]; + secondary: Type[]; + } + interface InferenceContext { + typeParameters: TypeParameter[]; + inferUnionTypes: boolean; + inferences: TypeInferences[]; + inferredTypes: Type[]; + failedTypeParameterIndex?: number; + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + isEarly?: boolean; + } + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string; + category: DiagnosticCategory; + code: number; + /** + * Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit + */ + isEarly?: boolean; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + codepage?: number; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noLibCheck?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + preserveConstEnums?: boolean; + removeComments?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + Latest = 2, + } + interface ParsedCommandLine { + options: CompilerOptions; + filenames: string[]; + errors: Diagnostic[]; + } + interface CommandLineOption { + name: string; + type: string | Map; + shortName?: string; + description?: DiagnosticMessage; + paramType?: DiagnosticMessage; + error?: DiagnosticMessage; + } + const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 127, + lineFeed = 10, + carriageReturn = 13, + lineSeparator = 8232, + paragraphSeparator = 8233, + nextLine = 133, + space = 32, + nonBreakingSpace = 160, + enQuad = 8192, + emQuad = 8193, + enSpace = 8194, + emSpace = 8195, + threePerEmSpace = 8196, + fourPerEmSpace = 8197, + sixPerEmSpace = 8198, + figureSpace = 8199, + punctuationSpace = 8200, + thinSpace = 8201, + hairSpace = 8202, + zeroWidthSpace = 8203, + narrowNoBreakSpace = 8239, + ideographicSpace = 12288, + mathematicalSpace = 8287, + ogham = 5760, + _ = 95, + $ = 36, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + ampersand = 38, + asterisk = 42, + at = 64, + backslash = 92, + backtick = 96, + bar = 124, + caret = 94, + closeBrace = 125, + closeBracket = 93, + closeParen = 41, + colon = 58, + comma = 44, + dot = 46, + doubleQuote = 34, + equals = 61, + exclamation = 33, + greaterThan = 62, + lessThan = 60, + minus = 45, + openBrace = 123, + openBracket = 91, + openParen = 40, + percent = 37, + plus = 43, + question = 63, + semicolon = 59, + singleQuote = 39, + slash = 47, + tilde = 126, + backspace = 8, + formFeed = 12, + byteOrderMark = 65279, + tab = 9, + verticalTab = 11, + } + interface CancellationToken { + isCancellationRequested(): boolean; + } + interface CompilerHost { + getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getDefaultLibFilename(options: CompilerOptions): string; + getCancellationToken?(): CancellationToken; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + } +} +declare module ts { + interface ErrorCallback { + (message: DiagnosticMessage): void; + } + interface CommentCallback { + (pos: number, end: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function computeLineStarts(text: string): number[]; + function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number; + function getLineAndCharacterOfPosition(lineStarts: number[], position: number): { + line: number; + character: number; + }; + function positionToLineAndCharacter(text: string, pos: number): { + line: number; + character: number; + }; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function isOctalDigit(ch: number): boolean; + function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner; +} +declare module ts { + function getNodeConstructor(kind: SyntaxKind): new () => Node; + function createNode(kind: SyntaxKind): Node; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function createCompilerHost(options: CompilerOptions): CompilerHost; + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; + function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; +} +declare module ts { + function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker; +} +declare module ts { + var servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + isOpen: boolean; + version: string; + getScriptSnapshot(): IScriptSnapshot; + getNamedDeclarations(): Declaration[]; + update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + } + /** + * 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 + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * This call returns the array containing the start position of every line. + * i.e."[0, 10, 55]". TODO: consider making this optional. The language service could + * always determine this (albeit in a more expensive manner). + */ + getLineStartPositions(): number[]; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + isLibFile: boolean; + } + interface Logger { + log(s: string): void; + trace(s: string): void; + error(s: string): void; + } + interface LanguageServiceHost extends Logger { + getCompilationSettings(): CompilerOptions; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptIsOpen(fileName: string): boolean; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): CancellationToken; + getCurrentDirectory(): string; + getDefaultLibFilename(options: CompilerOptions): string; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + getOutliningSpans(fileName: string): OutliningSpan[]; + getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getEmitOutput(fileName: string): EmitOutput; + getSourceFile(filename: string): SourceFile; + dispose(): void; + } + class TextSpan { + private _start; + private _length; + /** + * Creates a TextSpan instance beginning with the position Start and having the Length + * specified with length. + */ + constructor(start: number, length: number); + toJSON(key: any): any; + start(): number; + length(): number; + end(): number; + isEmpty(): boolean; + /** + * Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less + * than End, otherwise false. + * @param position The position to check. + */ + containsPosition(position: number): boolean; + /** + * Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false. + * @param span The span to check. + */ + containsTextSpan(span: TextSpan): boolean; + /** + * Determines whether the given span overlaps this span. Two spans are considered to overlap + * if they have positions in common and neither is empty. Empty spans do not overlap with any + * other span. Returns true if the spans overlap, false otherwise. + * @param span The span to check. + */ + overlapsWith(span: TextSpan): boolean; + /** + * Returns the overlap with the given span, or undefined if there is no overlap. + * @param span The span to check. + */ + overlap(span: TextSpan): TextSpan; + /** + * Determines whether span intersects this span. Two spans are considered to + * intersect if they have positions in common or the end of one span + * coincides with the start of the other span. Returns true if the spans intersect, false otherwise. + * @param The span to check. + */ + intersectsWithTextSpan(span: TextSpan): boolean; + intersectsWith(start: number, length: number): boolean; + /** + * Determines whether the given position intersects this span. + * A position is considered to intersect if it is between the start and + * end positions (inclusive) of this span. Returns true if the position intersects, false otherwise. + * @param position The position to check. + */ + intersectsWithPosition(position: number): boolean; + /** + * Returns the intersection with the given span, or undefined if there is no intersection. + * @param span The span to check. + */ + intersection(span: TextSpan): TextSpan; + /** + * Creates a new TextSpan from the given start and end positions + * as opposed to a position and length. + */ + static fromBounds(start: number, end: number): TextSpan; + } + class TextChangeRange { + static unchanged: TextChangeRange; + private _span; + private _newLength; + /** + * Initializes a new instance of TextChangeRange. + */ + constructor(span: TextSpan, newLength: number); + /** + * The span of text before the edit which is being changed + */ + span(): TextSpan; + /** + * Width of the span after the edit. A 0 here would represent a delete + */ + newLength(): number; + newSpan(): TextSpan; + isUnchanged(): boolean; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** 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. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitOutputStatus: EmitReturnStatus; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + Start = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult; + } + interface DocumentRegistry { + acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean): SourceFile; + updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + releaseDocument(filename: string, compilationSettings: CompilerOptions): void; + } + class ScriptElementKind { + static unknown: string; + static keyword: string; + static scriptElement: string; + static moduleElement: string; + static classElement: string; + static interfaceElement: string; + static typeElement: string; + static enumElement: string; + static variableElement: string; + static localVariableElement: string; + static functionElement: string; + static localFunctionElement: string; + static memberFunctionElement: string; + static memberGetAccessorElement: string; + static memberSetAccessorElement: string; + static memberVariableElement: string; + static constructorImplementationElement: string; + static callSignatureElement: string; + static indexSignatureElement: string; + static constructSignatureElement: string; + static parameterElement: string; + static typeParameterElement: string; + static primitiveType: string; + static label: string; + static alias: string; + static constElement: string; + static letElement: string; + } + class ScriptElementKindModifier { + static none: string; + static publicMemberModifier: string; + static privateMemberModifier: string; + static protectedMemberModifier: string; + static exportedModifier: string; + static ambientModifier: string; + static staticModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAlias: string; + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + class OperationCanceledException { + } + class CancellationTokenObject { + private cancellationToken; + static None: CancellationTokenObject; + constructor(cancellationToken: CancellationToken); + isCancellationRequested(): boolean; + throwIfCancellationRequested(): void; + } + function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile; + function createDocumentRegistry(): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService; + function createClassifier(host: Logger): Classifier; +} diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 8c36e0b88f6..95d17a7f0f2 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -34,15 +34,15 @@ var ts; var ts; (function (ts) { function forEach(array, callback) { - var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) { - break; + var result = callback(array[i]); + if (result) { + return result; } } } - return result; + return undefined; } ts.forEach = forEach; function contains(array, value) { @@ -521,24 +521,34 @@ var ts; return path; } ts.removeFileExtension = removeFileExtension; - var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\0-\19\t\v\f\b\0\r\n\u2028\u2029\u0085]/g; var escapedCharsMap = { + "\0": "\\0", "\t": "\\t", "\v": "\\v", "\f": "\\f", "\b": "\\b", - "\0": "\\0", "\r": "\\r", "\n": "\\n", + "\\": "\\\\", "\"": "\\\"", "\u2028": "\\u2028", "\u2029": "\\u2029", "\u0085": "\\u0085" }; function escapeString(s) { - return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { - return escapedCharsMap[c] || c; - }) : s; + s = backslashOrDoubleQuote.test(s) ? s.replace(backslashOrDoubleQuote, getReplacement) : s; + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || unicodeEscape(c); + } + function unicodeEscape(c) { + var hexCharCode = c.charCodeAt(0).toString(16); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } } ts.escapeString = escapeString; function Symbol(flags, name) { @@ -592,6 +602,204 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + 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(); + } + } + return { + 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 (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require('os'); + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = '\uFEFF' + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + _fs.writeSync(1, s); + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + function fileChanged(curr, prev) { + if (+curr.mtime <= +prev.mtime) { + return; + } + callback(fileName); + } + ; + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof module !== "undefined" && module.exports) { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); +var ts; (function (ts) { ts.Diagnostics = { Unterminated_string_literal: { code: 1002, category: 1 /* Error */, key: "Unterminated string literal." }, @@ -698,8 +906,7 @@ var ts; Type_argument_expected: { code: 1140, category: 1 /* Error */, key: "Type argument expected." }, String_literal_expected: { code: 1141, category: 1 /* Error */, key: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: 1 /* Error */, key: "Line break not permitted here." }, - catch_or_finally_expected: { code: 1143, category: 1 /* Error */, key: "'catch' or 'finally' expected." }, - Block_or_expected: { code: 1144, category: 1 /* Error */, key: "Block or ';' expected." }, + or_expected: { code: 1144, category: 1 /* Error */, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1 /* Error */, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: 1 /* Error */, key: "Declaration expected." }, Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1 /* Error */, key: "Import declarations in an internal module cannot reference an external module." }, @@ -712,12 +919,32 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1 /* Error */, key: "Computed property names are not allowed in enums." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: 1 /* Error */, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: 1 /* Error */, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1 /* Error */, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: 1 /* Error */, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: 1 /* Error */, key: "Computed property names are not allowed in interfaces." }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: 1 /* Error */, key: "Computed property names are not allowed in type literals." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1 /* Error */, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: 1 /* Error */, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: 1 /* Error */, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: 1 /* Error */, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: 1 /* Error */, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1 /* Error */, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: 1 /* Error */, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: 1 /* Error */, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: 1 /* Error */, key: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: 1 /* Error */, key: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: 1 /* Error */, key: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: 1 /* Error */, key: "A destructuring declaration must have an initializer." }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: 1 /* Error */, key: "Destructuring declarations are not allowed in ambient contexts." }, + Merge_conflict_marker_encountered: { code: 1184, category: 1 /* Error */, key: "Merge conflict marker encountered." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -810,8 +1037,6 @@ var ts; Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1 /* Error */, key: "Overload signature is not compatible with function implementation." }, Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1 /* Error */, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1 /* Error */, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: { code: 2397, category: 1 /* Error */, key: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter." }, - Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: { code: 2398, category: 1 /* Error */, key: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1 /* Error */, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1 /* Error */, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1 /* Error */, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, @@ -867,6 +1092,9 @@ var ts; Type_alias_0_circularly_references_itself: { code: 2456, category: 1 /* Error */, key: "Type alias '{0}' circularly references itself." }, Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1 /* Error */, key: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: 1 /* Error */, key: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: 1 /* Error */, key: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: 1 /* Error */, key: "Type '{0}' is not an array type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -989,6 +1217,7 @@ var ts; Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1 /* Error */, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1 /* Error */, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: 1 /* Error */, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1007,118 +1236,119 @@ var ts; 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: 1 /* Error */, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." }, - generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." } + Generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "Generators are not currently supported." }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: 1 /* Error */, key: "Computed property names are not currently supported." } }; })(ts || (ts = {})); var ts; (function (ts) { var textToToken = { - "any": 109 /* AnyKeyword */, - "boolean": 110 /* BooleanKeyword */, - "break": 64 /* BreakKeyword */, - "case": 65 /* CaseKeyword */, - "catch": 66 /* CatchKeyword */, - "class": 67 /* ClassKeyword */, - "continue": 69 /* ContinueKeyword */, - "const": 68 /* ConstKeyword */, - "constructor": 111 /* ConstructorKeyword */, - "debugger": 70 /* DebuggerKeyword */, - "declare": 112 /* DeclareKeyword */, - "default": 71 /* DefaultKeyword */, - "delete": 72 /* DeleteKeyword */, - "do": 73 /* DoKeyword */, - "else": 74 /* ElseKeyword */, - "enum": 75 /* EnumKeyword */, - "export": 76 /* ExportKeyword */, - "extends": 77 /* ExtendsKeyword */, - "false": 78 /* FalseKeyword */, - "finally": 79 /* FinallyKeyword */, - "for": 80 /* ForKeyword */, - "function": 81 /* FunctionKeyword */, - "get": 113 /* GetKeyword */, - "if": 82 /* IfKeyword */, - "implements": 100 /* ImplementsKeyword */, - "import": 83 /* ImportKeyword */, - "in": 84 /* InKeyword */, - "instanceof": 85 /* InstanceOfKeyword */, - "interface": 101 /* InterfaceKeyword */, - "let": 102 /* LetKeyword */, - "module": 114 /* ModuleKeyword */, - "new": 86 /* NewKeyword */, - "null": 87 /* NullKeyword */, - "number": 116 /* NumberKeyword */, - "package": 103 /* PackageKeyword */, - "private": 104 /* PrivateKeyword */, - "protected": 105 /* ProtectedKeyword */, - "public": 106 /* PublicKeyword */, - "require": 115 /* RequireKeyword */, - "return": 88 /* ReturnKeyword */, - "set": 117 /* SetKeyword */, - "static": 107 /* StaticKeyword */, - "string": 118 /* StringKeyword */, - "super": 89 /* SuperKeyword */, - "switch": 90 /* SwitchKeyword */, - "this": 91 /* ThisKeyword */, - "throw": 92 /* ThrowKeyword */, - "true": 93 /* TrueKeyword */, - "try": 94 /* TryKeyword */, - "type": 119 /* TypeKeyword */, - "typeof": 95 /* TypeOfKeyword */, - "var": 96 /* VarKeyword */, - "void": 97 /* VoidKeyword */, - "while": 98 /* WhileKeyword */, - "with": 99 /* WithKeyword */, - "yield": 108 /* YieldKeyword */, - "{": 13 /* OpenBraceToken */, - "}": 14 /* CloseBraceToken */, - "(": 15 /* OpenParenToken */, - ")": 16 /* CloseParenToken */, - "[": 17 /* OpenBracketToken */, - "]": 18 /* CloseBracketToken */, - ".": 19 /* DotToken */, - "...": 20 /* DotDotDotToken */, - ";": 21 /* SemicolonToken */, - ",": 22 /* CommaToken */, - "<": 23 /* LessThanToken */, - ">": 24 /* GreaterThanToken */, - "<=": 25 /* LessThanEqualsToken */, - ">=": 26 /* GreaterThanEqualsToken */, - "==": 27 /* EqualsEqualsToken */, - "!=": 28 /* ExclamationEqualsToken */, - "===": 29 /* EqualsEqualsEqualsToken */, - "!==": 30 /* ExclamationEqualsEqualsToken */, - "=>": 31 /* EqualsGreaterThanToken */, - "+": 32 /* PlusToken */, - "-": 33 /* MinusToken */, - "*": 34 /* AsteriskToken */, - "/": 35 /* SlashToken */, - "%": 36 /* PercentToken */, - "++": 37 /* PlusPlusToken */, - "--": 38 /* MinusMinusToken */, - "<<": 39 /* LessThanLessThanToken */, - ">>": 40 /* GreaterThanGreaterThanToken */, - ">>>": 41 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 42 /* AmpersandToken */, - "|": 43 /* BarToken */, - "^": 44 /* CaretToken */, - "!": 45 /* ExclamationToken */, - "~": 46 /* TildeToken */, - "&&": 47 /* AmpersandAmpersandToken */, - "||": 48 /* BarBarToken */, - "?": 49 /* QuestionToken */, - ":": 50 /* ColonToken */, - "=": 51 /* EqualsToken */, - "+=": 52 /* PlusEqualsToken */, - "-=": 53 /* MinusEqualsToken */, - "*=": 54 /* AsteriskEqualsToken */, - "/=": 55 /* SlashEqualsToken */, - "%=": 56 /* PercentEqualsToken */, - "<<=": 57 /* LessThanLessThanEqualsToken */, - ">>=": 58 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 60 /* AmpersandEqualsToken */, - "|=": 61 /* BarEqualsToken */, - "^=": 62 /* CaretEqualsToken */ + "any": 110 /* AnyKeyword */, + "boolean": 111 /* BooleanKeyword */, + "break": 65 /* BreakKeyword */, + "case": 66 /* CaseKeyword */, + "catch": 67 /* CatchKeyword */, + "class": 68 /* ClassKeyword */, + "continue": 70 /* ContinueKeyword */, + "const": 69 /* ConstKeyword */, + "constructor": 112 /* ConstructorKeyword */, + "debugger": 71 /* DebuggerKeyword */, + "declare": 113 /* DeclareKeyword */, + "default": 72 /* DefaultKeyword */, + "delete": 73 /* DeleteKeyword */, + "do": 74 /* DoKeyword */, + "else": 75 /* ElseKeyword */, + "enum": 76 /* EnumKeyword */, + "export": 77 /* ExportKeyword */, + "extends": 78 /* ExtendsKeyword */, + "false": 79 /* FalseKeyword */, + "finally": 80 /* FinallyKeyword */, + "for": 81 /* ForKeyword */, + "function": 82 /* FunctionKeyword */, + "get": 114 /* GetKeyword */, + "if": 83 /* IfKeyword */, + "implements": 101 /* ImplementsKeyword */, + "import": 84 /* ImportKeyword */, + "in": 85 /* InKeyword */, + "instanceof": 86 /* InstanceOfKeyword */, + "interface": 102 /* InterfaceKeyword */, + "let": 103 /* LetKeyword */, + "module": 115 /* ModuleKeyword */, + "new": 87 /* NewKeyword */, + "null": 88 /* NullKeyword */, + "number": 117 /* NumberKeyword */, + "package": 104 /* PackageKeyword */, + "private": 105 /* PrivateKeyword */, + "protected": 106 /* ProtectedKeyword */, + "public": 107 /* PublicKeyword */, + "require": 116 /* RequireKeyword */, + "return": 89 /* ReturnKeyword */, + "set": 118 /* SetKeyword */, + "static": 108 /* StaticKeyword */, + "string": 119 /* StringKeyword */, + "super": 90 /* SuperKeyword */, + "switch": 91 /* SwitchKeyword */, + "this": 92 /* ThisKeyword */, + "throw": 93 /* ThrowKeyword */, + "true": 94 /* TrueKeyword */, + "try": 95 /* TryKeyword */, + "type": 120 /* TypeKeyword */, + "typeof": 96 /* TypeOfKeyword */, + "var": 97 /* VarKeyword */, + "void": 98 /* VoidKeyword */, + "while": 99 /* WhileKeyword */, + "with": 100 /* WithKeyword */, + "yield": 109 /* YieldKeyword */, + "{": 14 /* OpenBraceToken */, + "}": 15 /* CloseBraceToken */, + "(": 16 /* OpenParenToken */, + ")": 17 /* CloseParenToken */, + "[": 18 /* OpenBracketToken */, + "]": 19 /* CloseBracketToken */, + ".": 20 /* DotToken */, + "...": 21 /* DotDotDotToken */, + ";": 22 /* SemicolonToken */, + ",": 23 /* CommaToken */, + "<": 24 /* LessThanToken */, + ">": 25 /* GreaterThanToken */, + "<=": 26 /* LessThanEqualsToken */, + ">=": 27 /* GreaterThanEqualsToken */, + "==": 28 /* EqualsEqualsToken */, + "!=": 29 /* ExclamationEqualsToken */, + "===": 30 /* EqualsEqualsEqualsToken */, + "!==": 31 /* ExclamationEqualsEqualsToken */, + "=>": 32 /* EqualsGreaterThanToken */, + "+": 33 /* PlusToken */, + "-": 34 /* MinusToken */, + "*": 35 /* AsteriskToken */, + "/": 36 /* SlashToken */, + "%": 37 /* PercentToken */, + "++": 38 /* PlusPlusToken */, + "--": 39 /* MinusMinusToken */, + "<<": 40 /* LessThanLessThanToken */, + ">>": 41 /* GreaterThanGreaterThanToken */, + ">>>": 42 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 43 /* AmpersandToken */, + "|": 44 /* BarToken */, + "^": 45 /* CaretToken */, + "!": 46 /* ExclamationToken */, + "~": 47 /* TildeToken */, + "&&": 48 /* AmpersandAmpersandToken */, + "||": 49 /* BarBarToken */, + "?": 50 /* QuestionToken */, + ":": 51 /* ColonToken */, + "=": 52 /* EqualsToken */, + "+=": 53 /* PlusEqualsToken */, + "-=": 54 /* MinusEqualsToken */, + "*=": 55 /* AsteriskEqualsToken */, + "/=": 56 /* SlashEqualsToken */, + "%=": 57 /* PercentEqualsToken */, + "<<=": 58 /* LessThanLessThanEqualsToken */, + ">>=": 59 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 61 /* AmpersandEqualsToken */, + "|=": 62 /* BarEqualsToken */, + "^=": 63 /* CaretEqualsToken */ }; 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,]; @@ -1235,12 +1465,14 @@ var ts; var ch = text.charCodeAt(pos); switch (ch) { case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; + } case 10 /* lineFeed */: pos++; - if (stopAfterLineBreak) + if (stopAfterLineBreak) { return pos; + } continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -1271,6 +1503,14 @@ var ts; continue; } break; + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -1282,6 +1522,28 @@ var ts; } } ts.skipTrivia = skipTrivia; + function isConflictMarkerTrivia(text, pos) { + if (pos > 0 && isLineBreak(text.charCodeAt(pos - 1))) { + var ch = text.charCodeAt(pos); + var markerLength = "<<<<<<<".length; + if ((pos + markerLength) < text.length) { + for (var i = 0, n = markerLength; i < n; i++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } + } + return ch === 61 /* equals */ || text.charCodeAt(pos + markerLength) === 32 /* space */; + } + } + return false; + } + function scanConflictMarkerTrivia(text, pos) { + var len = text.length; + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -1368,7 +1630,7 @@ var ts; return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - function createScanner(languageVersion, skipTrivia, text, onError, onComment) { + function createScanner(languageVersion, skipTrivia, text, onError) { var pos; var len; var startPos; @@ -1376,6 +1638,7 @@ var ts; var token; var tokenValue; var precedingLineBreak; + var tokenIsUnterminated; function error(message) { if (onError) { onError(message); @@ -1452,6 +1715,7 @@ var ts; while (true) { if (pos >= len) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1469,6 +1733,7 @@ var ts; } if (isLineBreak(ch)) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1485,21 +1750,22 @@ var ts; while (true) { if (pos >= len) { contents += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; break; } if (currChar === 36 /* $ */ && pos + 1 < len && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 10 /* TemplateHead */ : 11 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; break; } if (currChar === 92 /* backslash */) { @@ -1510,10 +1776,10 @@ var ts; } if (currChar === 13 /* carriageReturn */) { contents += text.substring(start, pos); - if (pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } - pos++; contents += "\n"; start = pos; continue; @@ -1615,11 +1881,31 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 63 /* Identifier */; + return token = 64 /* Identifier */; + } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; } function scan() { startPos = pos; precedingLineBreak = false; + tokenIsUnterminated = false; while (true) { tokenPos = pos; if (pos >= len) { @@ -1660,66 +1946,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 30 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 31 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 28 /* ExclamationEqualsToken */; + return pos += 2, token = 29 /* ExclamationEqualsToken */; } - return pos++, token = 45 /* ExclamationToken */; + return pos++, token = 46 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 7 /* StringLiteral */; + return token = 8 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PercentEqualsToken */; + return pos += 2, token = 57 /* PercentEqualsToken */; } - return pos++, token = 36 /* PercentToken */; + return pos++, token = 37 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 47 /* AmpersandAmpersandToken */; + return pos += 2, token = 48 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* AmpersandEqualsToken */; + return pos += 2, token = 61 /* AmpersandEqualsToken */; } - return pos++, token = 42 /* AmpersandToken */; + return pos++, token = 43 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 15 /* OpenParenToken */; + return pos++, token = 16 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 16 /* CloseParenToken */; + return pos++, token = 17 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* AsteriskEqualsToken */; + return pos += 2, token = 55 /* AsteriskEqualsToken */; } - return pos++, token = 34 /* AsteriskToken */; + return pos++, token = 35 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 37 /* PlusPlusToken */; + return pos += 2, token = 38 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 52 /* PlusEqualsToken */; + return pos += 2, token = 53 /* PlusEqualsToken */; } - return pos++, token = 32 /* PlusToken */; + return pos++, token = 33 /* PlusToken */; case 44 /* comma */: - return pos++, token = 22 /* CommaToken */; + return pos++, token = 23 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 38 /* MinusMinusToken */; + return pos += 2, token = 39 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 53 /* MinusEqualsToken */; + return pos += 2, token = 54 /* MinusEqualsToken */; } - return pos++, token = 33 /* MinusToken */; + return pos++, token = 34 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 20 /* DotDotDotToken */; + return pos += 3, token = 21 /* DotDotDotToken */; } - return pos++, token = 19 /* DotToken */; + return pos++, token = 20 /* DotToken */; case 47 /* slash */: if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; @@ -1729,9 +2015,6 @@ var ts; } pos++; } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } @@ -1757,20 +2040,18 @@ var ts; if (!commentClosed) { error(ts.Diagnostics.Asterisk_Slash_expected); } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } else { + tokenIsUnterminated = !commentClosed; return token = 3 /* MultiLineCommentTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* SlashEqualsToken */; + return pos += 2, token = 56 /* SlashEqualsToken */; } - return pos++, token = 35 /* SlashToken */; + return pos++, token = 36 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < len && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -1780,11 +2061,31 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 7 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 7 /* NumericLiteral */; } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; } case 49 /* _1 */: case 50 /* _2 */: @@ -1796,60 +2097,90 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; + return token = 7 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 50 /* ColonToken */; + return pos++, token = 51 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 21 /* SemicolonToken */; + return pos++, token = 22 /* SemicolonToken */; case 60 /* lessThan */: + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 57 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 58 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 39 /* LessThanLessThanToken */; + return pos += 2, token = 40 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 25 /* LessThanEqualsToken */; + return pos += 2, token = 26 /* LessThanEqualsToken */; } - return pos++, token = 23 /* LessThanToken */; + return pos++, token = 24 /* LessThanToken */; case 61 /* equals */: + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 29 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 30 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 27 /* EqualsEqualsToken */; + return pos += 2, token = 28 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 31 /* EqualsGreaterThanToken */; + return pos += 2, token = 32 /* EqualsGreaterThanToken */; } - return pos++, token = 51 /* EqualsToken */; + return pos++, token = 52 /* EqualsToken */; case 62 /* greaterThan */: - return pos++, token = 24 /* GreaterThanToken */; + if (isConflictMarkerTrivia(text, pos)) { + error(ts.Diagnostics.Merge_conflict_marker_encountered); + pos = scanConflictMarkerTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ConflictMarkerTrivia */; + } + } + return pos++, token = 25 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 49 /* QuestionToken */; + return pos++, token = 50 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 17 /* OpenBracketToken */; + return pos++, token = 18 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 18 /* CloseBracketToken */; + return pos++, token = 19 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* CaretEqualsToken */; + return pos += 2, token = 63 /* CaretEqualsToken */; } - return pos++, token = 44 /* CaretToken */; + return pos++, token = 45 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 13 /* OpenBraceToken */; + return pos++, token = 14 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 48 /* BarBarToken */; + return pos += 2, token = 49 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* BarEqualsToken */; + return pos += 2, token = 62 /* BarEqualsToken */; } - return pos++, token = 43 /* BarToken */; + return pos++, token = 44 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 14 /* CloseBraceToken */; + return pos++, token = 15 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 46 /* TildeToken */; + return pos++, token = 47 /* TildeToken */; case 92 /* backslash */: var ch = peekUnicodeEscape(); if (ch >= 0 && isIdentifierStart(ch)) { @@ -1885,37 +2216,39 @@ var ts; } } function reScanGreaterToken() { - if (token === 24 /* GreaterThanToken */) { + if (token === 25 /* 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 = 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 41 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 42 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 59 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 40 /* GreaterThanGreaterThanToken */; + return pos++, token = 41 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 26 /* GreaterThanEqualsToken */; + return pos++, token = 27 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) { + if (token === 36 /* SlashToken */ || token === 56 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; while (true) { if (p >= len) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -1942,16 +2275,16 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 8 /* RegularExpressionLiteral */; + token = 9 /* RegularExpressionLiteral */; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 14 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } - function tryScan(callback) { + function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; var saveTokenPos = tokenPos; @@ -1959,7 +2292,7 @@ var ts; var saveTokenValue = tokenValue; var savePrecedingLineBreak = precedingLineBreak; var result = callback(); - if (!result) { + if (!result || isLookahead) { pos = savePos; startPos = saveStartPos; tokenPos = saveTokenPos; @@ -1969,6 +2302,12 @@ var ts; } return result; } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } function setText(newText) { text = newText || ""; len = text.length; @@ -1990,36 +2329,89 @@ var ts; getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, + isIdentifier: function () { return token === 64 /* Identifier */ || token > 100 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 65 /* FirstReservedWord */ && token <= 100 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, - tryScan: tryScan + tryScan: tryScan, + lookAhead: lookAhead }; } ts.createScanner = createScanner; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(200 /* Count */); - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + for (var i = 0; i < declarations.length; i++) { + var declaration = declarations[i]; + if (declaration.kind === kind) { + return declaration; + } + } + return undefined; } - ts.getNodeConstructor = getNodeConstructor; - function createRootNode(kind, pos, end, flags) { - var node = new (getNodeConstructor(kind))(); - node.pos = pos; - node.end = end; - node.flags = flags; - return node; + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + ts.hasFlag = hasFlag; + function containsParseError(node) { + if (!hasFlag(node.parserContextFlags, 64 /* HasComputedThisNodeOrAnySubNodesHasError */)) { + var val = hasFlag(node.parserContextFlags, 16 /* ThisNodeHasError */) || ts.forEachChild(node, containsParseError); + if (val) { + node.parserContextFlags |= 32 /* ThisNodeOrAnySubNodesHasError */; + } + node.parserContextFlags |= 64 /* HasComputedThisNodeOrAnySubNodesHasError */; + } + return hasFlag(node.parserContextFlags, 32 /* ThisNodeOrAnySubNodesHasError */); + } + ts.containsParseError = containsParseError; function getSourceFileOfNode(node) { - while (node && node.kind !== 197 /* SourceFile */) + while (node && node.kind !== 207 /* SourceFile */) { node = node.parent; + } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; @@ -2033,19 +2425,29 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; + function isMissingNode(node) { + return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + } + ts.isMissingNode = isMissingNode; function getTokenPosOfNode(node, sourceFile) { - if (node.pos === node.end) { + if (isMissingNode(node)) { return node.pos; } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + if (isMissingNode(node)) { + return ""; + } var text = sourceFile.text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { + if (isMissingNode(node)) { + return ""; + } return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; @@ -2062,13 +2464,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function declarationNameToString(name) { - return name.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(name); + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = getTokenPosOfNode(node, file); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2084,12 +2486,13 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 195 /* ModuleDeclaration */: + case 194 /* EnumDeclaration */: + case 206 /* EnumMember */: errorSpan = node.name; break; } @@ -2105,7 +2508,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 191 /* EnumDeclaration */ && isConst(node); + return node.kind === 194 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -2117,19 +2520,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 172 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); - } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(isPrologueDirective(node)); - return node.expression.text === "use strict"; - } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { + if (node.kind === 124 /* Parameter */ || node.kind === 123 /* TypeParameter */) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -2138,184 +2534,35 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) - return cbNode(node); - } - function children(nodes) { - if (nodes) { - if (cbNodes) - return cbNodes(nodes); - var result; - for (var i = 0, len = nodes.length; i < len; i++) { - if (result = cbNode(nodes[i])) - break; - } - return result; - } - } - if (!node) - return; - switch (node.kind) { - case 121 /* QualifiedName */: - return child(node.left) || child(node.right); - case 122 /* TypeParameter */: - return child(node.name) || child(node.constraint); - case 123 /* Parameter */: - return child(node.name) || child(node.type) || child(node.initializer); - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - return child(node.name) || child(node.type) || child(node.initializer); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 132 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); - case 135 /* TypeQuery */: - return child(node.exprName); - case 136 /* TypeLiteral */: - return children(node.members); - case 137 /* ArrayType */: - return child(node.elementType); - case 138 /* TupleType */: - return children(node.elementTypes); - case 139 /* UnionType */: - return children(node.types); - case 140 /* ParenType */: - return child(node.type); - case 141 /* ArrayLiteral */: - return children(node.elements); - case 142 /* ObjectLiteral */: - return children(node.properties); - case 145 /* PropertyAccess */: - return child(node.left) || child(node.right); - case 146 /* IndexedAccess */: - return child(node.object) || child(node.index); - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 149 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); - case 150 /* TypeAssertion */: - return child(node.type) || child(node.operand); - case 151 /* ParenExpression */: - return child(node.expression); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return child(node.operand); - case 156 /* BinaryExpression */: - return child(node.left) || child(node.right); - case 157 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: - return children(node.statements); - case 163 /* VariableStatement */: - return children(node.declarations); - case 165 /* ExpressionStatement */: - return child(node.expression); - case 166 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 167 /* DoStatement */: - return child(node.statement) || child(node.expression); - case 168 /* WhileStatement */: - return child(node.expression) || child(node.statement); - case 169 /* ForStatement */: - return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 170 /* ForInStatement */: - return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - return child(node.label); - case 173 /* ReturnStatement */: - return child(node.expression); - case 174 /* WithStatement */: - return child(node.expression) || child(node.statement); - case 175 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return child(node.expression) || children(node.statements); - case 178 /* LabeledStatement */: - return child(node.label) || child(node.statement); - case 179 /* ThrowStatement */: - return child(node.expression); - case 180 /* TryStatement */: - return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 182 /* CatchBlock */: - return child(node.variable) || children(node.statements); - case 185 /* VariableDeclaration */: - return child(node.name) || child(node.type) || child(node.initializer); - case 188 /* ClassDeclaration */: - return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 189 /* InterfaceDeclaration */: - return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 190 /* TypeAliasDeclaration */: - return child(node.name) || child(node.type); - case 191 /* EnumDeclaration */: - return child(node.name) || children(node.members); - case 196 /* EnumMember */: - return child(node.name) || child(node.initializer); - case 192 /* ModuleDeclaration */: - return child(node.name) || child(node.body); - case 194 /* ImportDeclaration */: - return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 195 /* ExportAssignment */: - return child(node.exportName); - case 158 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); - case 159 /* TemplateSpan */: - return child(node.expression) || child(node.literal); - } - } - ts.forEachChild = forEachChild; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return visitor(node); - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - return forEachChild(node, traverse); + case 169 /* Block */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + return ts.forEachChild(node, traverse); } } } @@ -2323,19 +2570,36 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: + case 129 /* Constructor */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: return true; } } return false; } ts.isAnyFunction = isAnyFunction; + function isFunctionBlock(node) { + return node && node.kind === 169 /* Block */ && isAnyFunction(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 128 /* MethodDeclaration */ && node.parent.kind === 148 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { while (true) { node = node.parent; @@ -2352,20 +2616,22 @@ var ts; return undefined; } switch (node.kind) { - case 153 /* ArrowFunction */: + case 157 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 192 /* ModuleDeclaration */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 191 /* EnumDeclaration */: - case 197 /* SourceFile */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 195 /* ModuleDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 194 /* EnumDeclaration */: + case 207 /* SourceFile */: return node; } } @@ -2378,86 +2644,94 @@ var ts; return undefined; } switch (node.kind) { - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { return node.tag; } - return node.func; + return node.expression; } ts.getInvokedExpression = getInvokedExpression; function isExpression(node) { switch (node.kind) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 8 /* RegularExpressionLiteral */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 158 /* TemplateExpression */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 161 /* OmittedExpression */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: + case 9 /* RegularExpressionLiteral */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 153 /* TaggedTemplateExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 160 /* VoidExpression */: + case 158 /* DeleteExpression */: + case 159 /* TypeOfExpression */: + case 161 /* PrefixUnaryExpression */: + case 162 /* PostfixUnaryExpression */: + case 163 /* BinaryExpression */: + case 164 /* ConditionalExpression */: + case 165 /* TemplateExpression */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 167 /* OmittedExpression */: return true; case 121 /* QualifiedName */: - while (node.parent.kind === 121 /* QualifiedName */) + while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; - return node.parent.kind === 135 /* TypeQuery */; - case 63 /* Identifier */: - if (node.parent.kind === 135 /* TypeQuery */) { + } + return node.parent.kind === 138 /* TypeQuery */; + case 64 /* Identifier */: + if (node.parent.kind === 138 /* TypeQuery */) { return true; } - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: - case 196 /* EnumMember */: - case 143 /* PropertyAssignment */: + case 189 /* VariableDeclaration */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 206 /* EnumMember */: + case 204 /* PropertyAssignment */: + case 146 /* BindingElement */: return parent.initializer === node; - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 179 /* ThrowStatement */: - case 175 /* SwitchStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 184 /* ThrowStatement */: + case 182 /* SwitchStatement */: return parent.expression === node; - case 169 /* ForStatement */: + case 176 /* ForStatement */: return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return parent.variable === node || parent.expression === node; - case 150 /* TypeAssertion */: - return node === parent.operand; - case 159 /* TemplateSpan */: + case 154 /* TypeAssertionExpression */: + return node === parent.expression; + case 168 /* TemplateSpan */: return node === parent.expression; default: if (isExpression(parent)) { @@ -2468,22 +2742,61 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleImportDeclaration(node) { + return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */; + } + ts.isExternalModuleImportDeclaration = isExternalModuleImportDeclaration; + function getExternalModuleImportDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportDeclarationExpression = getExternalModuleImportDeclarationExpression; + function isInternalModuleImportDeclaration(node) { + return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind !== 199 /* ExternalModuleReference */; + } + ts.isInternalModuleImportDeclaration = isInternalModuleImportDeclaration; + function hasDotDotDotToken(node) { + return node && node.kind === 124 /* Parameter */ && node.dotDotDotToken !== undefined; + } + ts.hasDotDotDotToken = hasDotDotDotToken; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 124 /* Parameter */: + return node.questionToken !== undefined; + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return node.questionToken !== undefined; + case 205 /* ShorthandPropertyAssignment */: + case 204 /* PropertyAssignment */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; + return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { - return 6 /* FirstLiteralToken */ <= kind && kind <= 9 /* LastLiteralToken */; + return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 7 /* StringLiteral */ || kind === 9 /* NoSubstitutionTemplateLiteral */; + return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 9 /* FirstTemplateToken */ <= kind && kind <= 12 /* LastTemplateToken */; + return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return node.kind === 145 /* ArrayBindingPattern */ || node.kind === 144 /* ObjectBindingPattern */; + } + ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { if (node.flags & (2 /* Ambient */ | 1024 /* DeclarationFile */)) @@ -2495,24 +2808,27 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 122 /* TypeParameter */: - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 123 /* TypeParameter */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 190 /* FunctionDeclaration */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return true; } return false; @@ -2520,24 +2836,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 184 /* DebuggerStatement */: - case 167 /* DoStatement */: - case 165 /* ExpressionStatement */: - case 164 /* EmptyStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - case 178 /* LabeledStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 92 /* ThrowKeyword */: - case 180 /* TryStatement */: - case 163 /* VariableStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 195 /* ExportAssignment */: + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 188 /* DebuggerStatement */: + case 174 /* DoStatement */: + case 172 /* ExpressionStatement */: + case 171 /* EmptyStatement */: + case 177 /* ForInStatement */: + case 176 /* ForStatement */: + case 173 /* IfStatement */: + case 183 /* LabeledStatement */: + case 180 /* ReturnStatement */: + case 182 /* SwitchStatement */: + case 93 /* ThrowKeyword */: + case 185 /* TryStatement */: + case 170 /* VariableStatement */: + case 175 /* WhileStatement */: + case 181 /* WithStatement */: + case 198 /* ExportAssignment */: return true; default: return false; @@ -2545,19 +2861,45 @@ var ts; } ts.isStatement = isStatement; function isDeclarationOrFunctionExpressionOrCatchVariableName(name) { - if (name.kind !== 63 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { + if (name.kind !== 64 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 156 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 182 /* CatchBlock */) { - return parent.variable === name; + if (parent.kind === 203 /* CatchClause */) { + return parent.name === name; } return false; } ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; + function getClassBaseTypeNode(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 78 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassBaseTypeNode = getClassBaseTypeNode; + function getClassImplementedTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 101 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 78 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var i = 0, n = clauses.length; i < n; i++) { + if (clauses[i].token === kind) { + return clauses[i]; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; function tryResolveScriptReference(program, sourceFile, reference) { if (!program.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename); @@ -2568,16 +2910,16 @@ var ts; ts.tryResolveScriptReference = tryResolveScriptReference; function getAncestor(node, kind) { switch (kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return node; - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 194 /* EnumDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -2597,28 +2939,6 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - function parsingContextErrors(context) { - switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - } - } - ; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; @@ -2644,7 +2964,7 @@ var ts; } else { return { - diagnostic: ts.Diagnostics.Invalid_reference_directive_syntax, + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, isNoDefaultLib: false }; } @@ -2654,62 +2974,366 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 64 /* FirstKeyword */ <= token && token <= 119 /* LastKeyword */; + return 65 /* FirstKeyword */ <= token && token <= 120 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isUnterminatedTemplateEnd(node) { - ts.Debug.assert(isTemplateLiteralKind(node.kind)); - var sourceText = getSourceFileOfNode(node).text; - if (node.end !== sourceText.length) { - return false; - } - if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) { - return false; - } - return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0; - } - ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd; function isModifier(token) { switch (token) { - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - case 76 /* ExportKeyword */: - case 112 /* DeclareKeyword */: + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + case 77 /* ExportKeyword */: + case 113 /* DeclareKeyword */: + case 69 /* ConstKeyword */: return true; } return false; } ts.isModifier = isModifier; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(210 /* Count */); + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind) { + return new (getNodeConstructor(kind))(); + } + ts.createNode = createNode; + function forEachChild(node, cbNode, cbNodes) { + function child(node) { + if (node) { + return cbNode(node); + } + } + function children(nodes) { + if (nodes) { + if (cbNodes) { + return cbNodes(nodes); + } + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; + } + } + return undefined; + } + } + if (!node) { + return; + } + switch (node.kind) { + case 121 /* QualifiedName */: + return child(node.left) || child(node.right); + case 123 /* TypeParameter */: + return child(node.name) || child(node.constraint); + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + return children(node.modifiers) || child(node.propertyName) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + return children(node.modifiers) || child(node.asteriskToken) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + case 135 /* TypeReference */: + return child(node.typeName) || children(node.typeArguments); + case 138 /* TypeQuery */: + return child(node.exprName); + case 139 /* TypeLiteral */: + return children(node.members); + case 140 /* ArrayType */: + return child(node.elementType); + case 141 /* TupleType */: + return children(node.elementTypes); + case 142 /* UnionType */: + return children(node.types); + case 143 /* ParenthesizedType */: + return child(node.type); + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + return children(node.elements); + case 147 /* ArrayLiteralExpression */: + return children(node.elements); + case 148 /* ObjectLiteralExpression */: + return children(node.properties); + case 149 /* PropertyAccessExpression */: + return child(node.expression) || child(node.name); + case 150 /* ElementAccessExpression */: + return child(node.expression) || child(node.argumentExpression); + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return child(node.expression) || children(node.typeArguments) || children(node.arguments); + case 153 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 154 /* TypeAssertionExpression */: + return child(node.type) || child(node.expression); + case 155 /* ParenthesizedExpression */: + return child(node.expression); + case 158 /* DeleteExpression */: + return child(node.expression); + case 159 /* TypeOfExpression */: + return child(node.expression); + case 160 /* VoidExpression */: + return child(node.expression); + case 161 /* PrefixUnaryExpression */: + return child(node.operand); + case 166 /* YieldExpression */: + return child(node.asteriskToken) || child(node.expression); + case 162 /* PostfixUnaryExpression */: + return child(node.operand); + case 163 /* BinaryExpression */: + return child(node.left) || child(node.right); + case 164 /* ConditionalExpression */: + return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: + return children(node.statements); + case 207 /* SourceFile */: + return children(node.statements) || child(node.endOfFileToken); + case 170 /* VariableStatement */: + return children(node.modifiers) || children(node.declarations); + case 172 /* ExpressionStatement */: + return child(node.expression); + case 173 /* IfStatement */: + return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + case 174 /* DoStatement */: + return child(node.statement) || child(node.expression); + case 175 /* WhileStatement */: + return child(node.expression) || child(node.statement); + case 176 /* ForStatement */: + return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + case 177 /* ForInStatement */: + return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + return child(node.label); + case 180 /* ReturnStatement */: + return child(node.expression); + case 181 /* WithStatement */: + return child(node.expression) || child(node.statement); + case 182 /* SwitchStatement */: + return child(node.expression) || children(node.clauses); + case 200 /* CaseClause */: + return child(node.expression) || children(node.statements); + case 201 /* DefaultClause */: + return children(node.statements); + case 183 /* LabeledStatement */: + return child(node.label) || child(node.statement); + case 184 /* ThrowStatement */: + return child(node.expression); + case 185 /* TryStatement */: + return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + case 203 /* CatchClause */: + return child(node.name) || child(node.type) || child(node.block); + case 191 /* ClassDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 192 /* InterfaceDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 193 /* TypeAliasDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type); + case 194 /* EnumDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.members); + case 206 /* EnumMember */: + return child(node.name) || child(node.initializer); + case 195 /* ModuleDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.body); + case 197 /* ImportDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.moduleReference); + case 198 /* ExportAssignment */: + return children(node.modifiers) || child(node.exportName); + case 165 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 168 /* TemplateSpan */: + return child(node.expression) || child(node.literal); + case 122 /* ComputedPropertyName */: + return child(node.expression); + case 202 /* HeritageClause */: + return children(node.types); + case 199 /* ExternalModuleReference */: + return child(node.expression); + } + } + ts.forEachChild = forEachChild; + function createCompilerHost(options) { + var currentDirectory; + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(filename, languageVersion, onError) { + try { + var text = ts.sys.readFile(filename, options.charset); + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText : e.message); + } + text = ""; + } + return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined; + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + try { + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + return { + getSourceFile: getSourceFile, + getDefaultLibFilename: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"); }, + writeFile: writeFile, + getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return ts.sys.newLine; } + }; + } + ts.createCompilerHost = createCompilerHost; + function parsingContextErrors(context) { + switch (context) { + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* TypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + } + } + ; function modifierToFlag(token) { switch (token) { - case 107 /* StaticKeyword */: return 128 /* Static */; - case 106 /* PublicKeyword */: return 16 /* Public */; - case 105 /* ProtectedKeyword */: return 64 /* Protected */; - case 104 /* PrivateKeyword */: return 32 /* Private */; - case 76 /* ExportKeyword */: return 1 /* Export */; - case 112 /* DeclareKeyword */: return 2 /* Ambient */; + case 108 /* StaticKeyword */: return 128 /* Static */; + case 107 /* PublicKeyword */: return 16 /* Public */; + case 106 /* ProtectedKeyword */: return 64 /* Protected */; + case 105 /* PrivateKeyword */: return 32 /* Private */; + case 77 /* ExportKeyword */: return 1 /* Export */; + case 113 /* DeclareKeyword */: return 2 /* Ambient */; + case 69 /* ConstKeyword */: return 4096 /* Const */; } return 0; } - function createSourceFile(filename, sourceText, languageVersion, version, isOpen) { - if (isOpen === void 0) { isOpen = false; } - var file; - var scanner; - var token; + function fixupParentReferences(sourceFile) { + var parent = sourceFile; + function walk(n) { + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, walk); + parent = saveParent; + } + } + forEachChild(sourceFile, walk); + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 64 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); + } + function isUseStrictPrologueDirective(sourceFile, node) { + ts.Debug.assert(ts.isPrologueDirective(node)); + var nodeText = ts.getSourceTextOfNodeFromSourceFile(sourceFile, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; + } + function createSourceFile(filename, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } var parsingContext; - var commentRanges; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var lineStarts; - var lookAheadMode = 0 /* NotLookingAhead */; var contextFlags = 0; + var parseErrorBeforeNextFinishedNode = false; + var sourceFile = createNode(207 /* SourceFile */, 0); + if (ts.fileExtensionIs(filename, ".d.ts")) { + sourceFile.flags = 1024 /* DeclarationFile */; + } + sourceFile.end = sourceText.length; + sourceFile.filename = ts.normalizePath(filename); + sourceFile.text = sourceText; + sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; + sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; + sourceFile.getLineStarts = getLineStarts; + sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; + sourceFile.referenceDiagnostics = []; + sourceFile.parseDiagnostics = []; + sourceFile.grammarDiagnostics = []; + sourceFile.semanticDiagnostics = []; + processReferenceComments(); + var scanner = ts.createScanner(languageVersion, true, sourceText, scanError); + var token = nextToken(); + sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + sourceFile.externalModuleIndicator = getExternalModuleIndicator(); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.languageVersion = languageVersion; + sourceFile.identifiers = identifiers; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + return sourceFile; function setContextFlag(val, flag) { if (val) { contextFlags |= flag; @@ -2787,29 +3411,21 @@ var ts; function getPositionFromSourceLineAndCharacter(line, character) { return ts.getPositionFromLineAndCharacter(getLineStarts(), line, character); } - function error(message, arg0, arg1, arg2) { + function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; - errorAtPos(start, length, message, arg0, arg1, arg2); + parseErrorAtPosition(start, length, message, arg0); } - function errorAtPos(start, length, message, arg0, arg1, arg2) { - var lastErrorPos = file.parseDiagnostics.length ? file.parseDiagnostics[file.parseDiagnostics.length - 1].start : -1; - if (start !== lastErrorPos) { - var diagnostic = ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); - diagnostic.isParseError = true; - file.parseDiagnostics.push(diagnostic); - } - if (lookAheadMode === 1 /* NoErrorYet */) { - lookAheadMode = 2 /* Error */; + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); + if (!lastError || start !== lastError.start) { + sourceFile.parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); } + parseErrorBeforeNextFinishedNode = true; } function scanError(message) { var pos = scanner.getTextPos(); - errorAtPos(pos, 0, message); - } - function onComment(pos, end) { - if (commentRanges) - commentRanges.push({ pos: pos, end: end }); + parseErrorAtPosition(pos, 0, message); } function getNodePos() { return scanner.getStartPos(); @@ -2832,49 +3448,46 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } - function lookAheadHelper(callback, alwaysResetState) { + function speculationHelper(callback, isLookAhead) { var saveToken = token; - var saveSyntacticErrorsLength = file.parseDiagnostics.length; - var saveLookAheadMode = lookAheadMode; - lookAheadMode = 1 /* NoErrorYet */; - var result = callback(); - ts.Debug.assert(lookAheadMode === 2 /* Error */ || lookAheadMode === 1 /* NoErrorYet */); - if (lookAheadMode === 2 /* Error */) { - result = undefined; - } - lookAheadMode = saveLookAheadMode; - if (!result || alwaysResetState) { + var saveParseDiagnosticsLength = sourceFile.parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { token = saveToken; - file.parseDiagnostics.length = saveSyntacticErrorsLength; + sourceFile.parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; } return result; } function lookAhead(callback) { - var result; - scanner.tryScan(function () { - result = lookAheadHelper(callback, true); - return false; - }); - return result; + return speculationHelper(callback, true); } function tryParse(callback) { - return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); + return speculationHelper(callback, false); } function isIdentifier() { - if (token === 63 /* Identifier */) { + if (token === 64 /* Identifier */) { return true; } - if (token === 108 /* YieldKeyword */ && inYieldContext()) { + if (token === 109 /* YieldKeyword */ && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */; + return inStrictModeContext() ? token > 109 /* LastFutureReservedWord */ : token > 100 /* LastReservedWord */; } - function parseExpected(t) { - if (token === t) { + function parseExpected(kind, diagnosticMessage, arg0) { + if (token === kind) { nextToken(); return true; } - error(ts.Diagnostics._0_expected, ts.tokenToString(t)); + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } return false; } function parseOptional(t) { @@ -2893,19 +3506,20 @@ var ts; return undefined; } function canParseSemicolon() { - if (token === 21 /* SemicolonToken */) { + if (token === 22 /* SemicolonToken */) { return true; } - return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } - function parseSemicolon() { + function parseSemicolon(diagnosticMessage) { if (canParseSemicolon()) { - if (token === 21 /* SemicolonToken */) { + if (token === 22 /* SemicolonToken */) { nextToken(); } + return true; } else { - error(ts.Diagnostics._0_expected, ";"); + return parseExpected(22 /* SemicolonToken */, diagnosticMessage); } } function createNode(kind, pos) { @@ -2923,54 +3537,88 @@ var ts; if (contextFlags) { node.parserContextFlags = contextFlags; } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ThisNodeHasError */; + } return node; } - function createMissingNode(pos) { - return createNode(120 /* Missing */, pos); + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); } function internIdentifier(text) { - text = escapeIdentifier(text); + text = ts.escapeIdentifier(text); return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); } - function createIdentifier(isIdentifier) { + function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(63 /* Identifier */); + var node = createNode(64 /* Identifier */); node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - error(ts.Diagnostics.Identifier_expected); - var node = createMissingNode(); - node.text = ""; - return node; + return createMissingNode(64 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } - function parseIdentifier() { - return createIdentifier(isIdentifier()); + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(token >= 63 /* Identifier */); + return createIdentifier(isIdentifierOrKeyword()); } - function isPropertyName() { - return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + function isLiteralPropertyName() { + return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */; } function parsePropertyName() { - if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { + if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { return parseLiteralNode(true); } + if (token === 18 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } return parseIdentifierName(); } + function parseComputedPropertyName() { + var node = createNode(122 /* ComputedPropertyName */); + parseExpected(18 /* OpenBracketToken */); + var yieldContext = inYieldContext(); + if (inGeneratorParameterContext()) { + setYieldContext(false); + } + node.expression = allowInAnd(parseExpression); + if (inGeneratorParameterContext()) { + setYieldContext(yieldContext); + } + parseExpected(19 /* CloseBracketToken */); + return finishNode(node); + } function parseContextualModifier(t) { - return token === t && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || isPropertyName(); - }); + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + nextToken(); + return canFollowModifier(); } function parseAnyContextualModifier() { - return isModifier(token) && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName(); - }); + return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); + } + function nextTokenCanFollowContextualModifier() { + if (token === 69 /* ConstKeyword */) { + return nextToken() === 76 /* EnumKeyword */; + } + nextToken(); + return canFollowModifier(); + } + function canFollowModifier() { + return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); } function isListElement(kind, inErrorRecovery) { switch (kind) { @@ -2981,32 +3629,49 @@ var ts; case 4 /* SwitchClauseStatements */: return isStatement(inErrorRecovery); case 3 /* SwitchClauses */: - return token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; + return token === 66 /* CaseKeyword */ || token === 72 /* DefaultKeyword */; case 5 /* TypeMembers */: return isStartOfTypeMember(); case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: - return isPropertyName(); - case 11 /* ObjectLiteralMembers */: - return token === 34 /* AsteriskToken */ || isPropertyName(); - case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + case 13 /* ObjectLiteralMembers */: + return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); + case 10 /* ObjectBindingElements */: + return isLiteralPropertyName(); + case 8 /* TypeReferences */: + return isIdentifier() && !isNotHeritageClauseTypeName(); case 9 /* VariableDeclarations */: - case 14 /* TypeParameters */: + return isIdentifierOrPattern(); + case 11 /* ArrayBindingElements */: + return token === 23 /* CommaToken */ || isIdentifierOrPattern(); + case 16 /* TypeParameters */: return isIdentifier(); - case 10 /* ArgumentExpressions */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 12 /* ArrayLiteralMembers */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 13 /* Parameters */: + case 12 /* ArgumentExpressions */: + return token === 23 /* CommaToken */ || isStartOfExpression(); + case 14 /* ArrayLiteralMembers */: + return token === 23 /* CommaToken */ || isStartOfExpression(); + case 15 /* Parameters */: return isStartOfParameter(); - case 15 /* TypeArguments */: - case 16 /* TupleElementTypes */: - return token === 22 /* CommaToken */ || isStartOfType(); + case 17 /* TypeArguments */: + case 18 /* TupleElementTypes */: + return token === 23 /* CommaToken */ || isStartOfType(); + case 19 /* HeritageClauses */: + return isHeritageClause(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function isNotHeritageClauseTypeName() { + if (token === 101 /* ImplementsKeyword */ || token === 78 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsIdentifier); + } + return false; + } function isListTerminator(kind) { if (token === 1 /* EndOfFileToken */) { return true; @@ -3018,41 +3683,45 @@ var ts; case 5 /* TypeMembers */: case 6 /* ClassMembers */: case 7 /* EnumMembers */: - case 11 /* ObjectLiteralMembers */: - return token === 14 /* CloseBraceToken */; + case 13 /* ObjectLiteralMembers */: + case 10 /* ObjectBindingElements */: + return token === 15 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: - return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 8 /* BaseTypeReferences */: - return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; + return token === 15 /* CloseBraceToken */ || token === 66 /* CaseKeyword */ || token === 72 /* DefaultKeyword */; + case 8 /* TypeReferences */: + return token === 14 /* OpenBraceToken */ || token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 14 /* TypeParameters */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */ || token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; - case 10 /* ArgumentExpressions */: - return token === 16 /* CloseParenToken */ || token === 21 /* SemicolonToken */; - case 12 /* ArrayLiteralMembers */: - case 16 /* TupleElementTypes */: - return token === 18 /* CloseBracketToken */; - case 13 /* Parameters */: - return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; - case 15 /* TypeArguments */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; + case 16 /* TypeParameters */: + return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; + case 12 /* ArgumentExpressions */: + return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + case 14 /* ArrayLiteralMembers */: + case 18 /* TupleElementTypes */: + case 11 /* ArrayBindingElements */: + return token === 19 /* CloseBracketToken */; + case 15 /* Parameters */: + return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */; + case 17 /* TypeArguments */: + return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + case 19 /* HeritageClauses */: + return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { if (canParseSemicolon()) { return true; } - if (token === 84 /* InKeyword */) { + if (token === 85 /* InKeyword */) { return true; } - if (token === 31 /* EqualsGreaterThanToken */) { + if (token === 32 /* EqualsGreaterThanToken */) { return true; } return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 17 /* Count */; kind++) { + for (var kind = 0; kind < 20 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -3071,9 +3740,9 @@ var ts; if (isListElement(kind, false)) { var element = parseElement(); result.push(element); - if (!inStrictModeContext() && checkForStrictMode) { - if (isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { + if (checkForStrictMode && !inStrictModeContext()) { + if (ts.isPrologueDirective(element)) { + if (isUseStrictPrologueDirective(sourceFile, element)) { setStrictModeContext(true); checkForStrictMode = false; } @@ -3082,13 +3751,10 @@ var ts; checkForStrictMode = false; } } + continue; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } setStrictModeContext(savedStrictModeContext); @@ -3096,6 +3762,14 @@ var ts; parsingContext = saveParsingContext; return result; } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } function parseDelimitedList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -3106,24 +3780,21 @@ var ts; if (isListElement(kind, false)) { result.push(parseElement()); commaStart = scanner.getTokenPos(); - if (parseOptional(22 /* CommaToken */)) { + if (parseOptional(23 /* CommaToken */)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - error(ts.Diagnostics._0_expected, ","); + parseExpected(23 /* CommaToken */); + continue; } - else if (isListTerminator(kind)) { + if (isListTerminator(kind)) { break; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } if (commaStart >= 0) { @@ -3148,46 +3819,53 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords) { - var entity = parseIdentifier(); - while (parseOptional(19 /* DotToken */)) { + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); + while (parseOptional(20 /* DotToken */)) { var node = createNode(121 /* QualifiedName */, entity.pos); node.left = entity; - node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); + node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); } return entity; } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(64 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } function parseTokenNode() { var node = createNode(token); nextToken(); return finishNode(node); } function parseTemplateExpression() { - var template = createNode(158 /* TemplateExpression */); + var template = createNode(165 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 11 /* TemplateMiddle */); + } while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(159 /* TemplateSpan */); + var span = createNode(168 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 14 /* CloseBraceToken */) { + if (token === 15 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - error(ts.Diagnostics.Invalid_template_literal_expected); - literal = createMissingNode(); - literal.text = ""; + literal = createMissingNode(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -3196,58 +3874,57 @@ var ts; var node = createNode(token); var text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 6 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + if (node.kind === 7 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 8192 /* OctalLiteral */; } return node; } - function parseStringLiteral() { - if (token === 7 /* StringLiteral */) { - return parseLiteralNode(true); - } - error(ts.Diagnostics.String_literal_expected); - return createMissingNode(); - } function parseTypeReference() { - var node = createNode(132 /* TypeReference */); - node.typeName = parseEntityName(false); - if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { - node.typeArguments = parseTypeArguments(); + var node = createNode(135 /* TypeReference */); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { + node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(135 /* TypeQuery */); - parseExpected(95 /* TypeOfKeyword */); + var node = createNode(138 /* TypeQuery */); + parseExpected(96 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(122 /* TypeParameter */); + var node = createNode(123 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(77 /* ExtendsKeyword */)) { + if (parseOptional(78 /* ExtendsKeyword */)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } else { - node.expression = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); } } return finishNode(node); } function parseTypeParameters() { - if (token === 23 /* LessThanToken */) { - return parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 23 /* LessThanToken */, 24 /* GreaterThanToken */); + if (token === 24 /* LessThanToken */) { + return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { - return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + if (parseOptional(51 /* ColonToken */)) { + return token === 8 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); + } + return undefined; } function isStartOfParameter() { - return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token); } function setModifiers(node, modifiers) { if (modifiers) { @@ -3256,19 +3933,14 @@ var ts; } } function parseParameter() { - var node = createNode(123 /* Parameter */); - var modifiers = parseModifiers(); - setModifiers(node, modifiers); - if (parseOptional(20 /* DotDotDotToken */)) { - node.flags |= 8 /* Rest */; - } - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier(); - if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { + var node = createNode(124 /* Parameter */); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - if (parseOptional(49 /* QuestionToken */)) { - node.flags |= 4 /* QuestionMark */; - } + node.questionToken = parseOptionalToken(50 /* QuestionToken */); node.type = parseParameterType(); node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); return finishNode(node); @@ -3276,17 +3948,10 @@ var ts; function parseParameterInitializer() { return parseInitializer(true); } - function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) { - var signature = {}; - fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature); - return signature; - } - function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) { - if (kind === 130 /* ConstructSignature */) { - parseExpected(86 /* NewKeyword */); - } + function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 32 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -3295,98 +3960,146 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext) { - if (parseExpected(15 /* OpenParenToken */)) { + function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { + if (parseExpected(16 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(13 /* Parameters */, parseParameter); - parseExpected(16 /* CloseParenToken */); + var result = parseDelimitedList(15 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); + if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + return undefined; + } return result; } - return createMissingList(); + return requireCompleteParameterList ? undefined : createMissingList(); } - function parseSignatureMember(kind, returnToken) { + function parseTypeMemberSemicolon() { + if (parseSemicolon()) { + return; + } + parseOptional(23 /* CommaToken */); + } + function parseSignatureMember(kind) { var node = createNode(kind); - fillSignature(kind, returnToken, false, false, node); - parseSemicolon(); + if (kind === 133 /* ConstructSignature */) { + parseExpected(87 /* NewKeyword */); + } + fillSignature(51 /* ColonToken */, false, false, node); + parseTypeMemberSemicolon(); return finishNode(node); } - function parseIndexSignatureMember(fullStart, modifiers) { - var node = createNode(131 /* IndexSignature */, fullStart); + function isIndexSignature() { + if (token !== 18 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */) { + return true; + } + if (token !== 50 /* QuestionToken */) { + return false; + } + nextToken(); + return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + } + function parseIndexSignatureDeclaration(fullStart, modifiers) { + var node = createNode(134 /* IndexSignature */, fullStart); setModifiers(node, modifiers); - node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); + node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethod() { + function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var flags = 0; - if (parseOptional(49 /* QuestionToken */)) { - flags = 4 /* QuestionMark */; - } - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var method = createNode(127 /* MethodSignature */, fullStart); method.name = name; - method.flags = flags; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method); - parseSemicolon(); + method.questionToken = questionToken; + fillSignature(51 /* ColonToken */, false, false, method); + parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(124 /* Property */, fullStart); + var property = createNode(125 /* PropertySignature */, fullStart); property.name = name; - property.flags = flags; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(property); } } function isStartOfTypeMember() { switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 17 /* OpenBracketToken */: + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + case 18 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); } } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 50 /* QuestionToken */ || token === 51 /* ColonToken */ || canParseSemicolon(); + } function parseTypeMember() { switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); - case 17 /* OpenBracketToken */: - return parseIndexSignatureMember(scanner.getStartPos(), undefined); - case 86 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { - return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + return parseSignatureMember(132 /* CallSignature */); + case 18 /* OpenBracketToken */: + return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined) : parsePropertyOrMethodSignature(); + case 87 /* NewKeyword */: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(133 /* ConstructSignature */); } - case 7 /* StringLiteral */: - case 6 /* NumericLiteral */: - return parsePropertyOrMethod(); + case 8 /* StringLiteral */: + case 7 /* NumericLiteral */: + return parsePropertyOrMethodSignature(); default: - if (token >= 63 /* Identifier */) { - return parsePropertyOrMethod(); + if (isIdentifierOrKeyword()) { + return parsePropertyOrMethodSignature(); } } } + function isStartOfConstructSignature() { + nextToken(); + return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + } function parseTypeLiteral() { - var node = createNode(136 /* TypeLiteral */); - node.members = parseObjectType(); + var node = createNode(139 /* TypeLiteral */); + node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseObjectType() { + function parseObjectTypeMembers() { var members; - if (parseExpected(13 /* OpenBraceToken */)) { + if (parseExpected(14 /* OpenBraceToken */)) { members = parseList(5 /* TypeMembers */, false, parseTypeMember); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { members = createMissingList(); @@ -3394,118 +4107,123 @@ var ts; return members; } function parseTupleType() { - var node = createNode(138 /* TupleType */); - node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); + var node = createNode(141 /* TupleType */); + node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } - function parseParenType() { - var node = createNode(140 /* ParenType */); - parseExpected(15 /* OpenParenToken */); + function parseParenthesizedType() { + var node = createNode(143 /* ParenthesizedType */); + parseExpected(16 /* OpenParenToken */); node.type = parseType(); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); return finishNode(node); } - function parseFunctionType(typeKind) { - var node = createNode(typeKind); - fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node); + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 137 /* ConstructorType */) { + parseExpected(87 /* NewKeyword */); + } + fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 19 /* DotToken */ ? undefined : node; + return token === 20 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 95 /* TypeOfKeyword */: + case 98 /* VoidKeyword */: + return parseTokenNode(); + case 96 /* TypeOfKeyword */: return parseTypeQuery(); - case 13 /* OpenBraceToken */: + case 14 /* OpenBraceToken */: return parseTypeLiteral(); - case 17 /* OpenBracketToken */: + case 18 /* OpenBracketToken */: return parseTupleType(); - case 15 /* OpenParenToken */: - return parseParenType(); + case 16 /* OpenParenToken */: + return parseParenthesizedType(); default: - if (isIdentifier()) { - return parseTypeReference(); - } + return parseTypeReference(); } - error(ts.Diagnostics.Type_expected); - return createMissingNode(); } function isStartOfType() { switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 95 /* TypeOfKeyword */: - case 13 /* OpenBraceToken */: - case 17 /* OpenBracketToken */: - case 23 /* LessThanToken */: - case 86 /* NewKeyword */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: + case 98 /* VoidKeyword */: + case 96 /* TypeOfKeyword */: + case 14 /* OpenBraceToken */: + case 18 /* OpenBracketToken */: + case 24 /* LessThanToken */: + case 87 /* NewKeyword */: return true; - case 15 /* OpenParenToken */: - return lookAhead(function () { - nextToken(); - return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - }); + case 16 /* OpenParenToken */: + return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } } - function parsePrimaryType() { + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { - parseExpected(18 /* CloseBracketToken */); - var node = createNode(137 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { + parseExpected(19 /* CloseBracketToken */); + var node = createNode(140 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionType() { - var type = parsePrimaryType(); - if (token === 43 /* BarToken */) { + function parseUnionTypeOrHigher() { + var type = parseArrayTypeOrHigher(); + if (token === 44 /* BarToken */) { var types = [type]; types.pos = type.pos; - while (parseOptional(43 /* BarToken */)) { - types.push(parsePrimaryType()); + while (parseOptional(44 /* BarToken */)) { + types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(139 /* UnionType */, type.pos); + var node = createNode(142 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } return type; } function isStartOfFunctionType() { - return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { + if (token === 24 /* LessThanToken */) { + return true; + } + return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 50 /* QuestionToken */ || token === 52 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { return true; } - if (isIdentifier() || isModifier(token)) { + if (token === 17 /* CloseParenToken */) { nextToken(); - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 32 /* EqualsGreaterThanToken */) { return true; } - if (token === 16 /* CloseParenToken */) { - nextToken(); - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - } } - return false; - }); + } + return false; } function parseType() { var savedYieldContext = inYieldContext(); @@ -3519,71 +4237,74 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionType(133 /* FunctionType */); + return parseFunctionOrConstructorType(136 /* FunctionType */); } - if (token === 86 /* NewKeyword */) { - return parseFunctionType(134 /* ConstructorType */); + if (token === 87 /* NewKeyword */) { + return parseFunctionOrConstructorType(137 /* ConstructorType */); } - return parseUnionType(); + return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(50 /* ColonToken */) ? parseType() : undefined; + return parseOptional(51 /* ColonToken */) ? parseType() : undefined; } function isStartOfExpression() { switch (token) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 15 /* OpenParenToken */: - case 17 /* OpenBracketToken */: - case 13 /* OpenBraceToken */: - case 81 /* FunctionKeyword */: - case 86 /* NewKeyword */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - case 23 /* LessThanToken */: - case 63 /* Identifier */: - case 108 /* YieldKeyword */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 11 /* TemplateHead */: + case 16 /* OpenParenToken */: + case 18 /* OpenBracketToken */: + case 14 /* OpenBraceToken */: + case 82 /* FunctionKeyword */: + case 87 /* NewKeyword */: + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: + case 46 /* ExclamationToken */: + case 73 /* DeleteKeyword */: + case 96 /* TypeOfKeyword */: + case 98 /* VoidKeyword */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: + case 24 /* LessThanToken */: + case 64 /* Identifier */: + case 109 /* YieldKeyword */: return true; default: + if (isBinaryOperator()) { + return true; + } return isIdentifier(); } } function isStartOfExpressionStatement() { - return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); + return token !== 14 /* OpenBraceToken */ && token !== 82 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression() { - var expr = parseAssignmentExpression(); - while (parseOptional(22 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression()); + var expr = parseAssignmentExpressionOrHigher(); + while (parseOptional(23 /* CommaToken */)) { + expr = makeBinaryExpression(expr, 23 /* CommaToken */, parseAssignmentExpressionOrHigher()); } return expr; } function parseInitializer(inParameter) { - if (token !== 51 /* EqualsToken */) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) { + if (token !== 52 /* EqualsToken */) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { return undefined; } } - parseExpected(51 /* EqualsToken */); - return parseAssignmentExpression(); + parseExpected(52 /* EqualsToken */); + return parseAssignmentExpressionOrHigher(); } - function parseAssignmentExpression() { + function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { return parseYieldExpression(); } @@ -3591,38 +4312,39 @@ var ts; if (arrowExpression) { return arrowExpression; } - var expr = parseConditionalExpression(); - if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { + var expr = parseBinaryExpressionOrHigher(0); + if (expr.kind === 64 /* Identifier */ && token === 32 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } - if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) { + if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { var operator = token; nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpression()); + return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); } - return expr; + return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 108 /* YieldKeyword */) { + if (token === 109 /* YieldKeyword */) { if (inYieldContext()) { return true; } if (inStrictModeContext()) { return true; } - return lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - }); + return lookAhead(nextTokenIsIdentifierOnSameLine); } return false; } - function parseYieldExpression() { - var node = createNode(160 /* YieldExpression */); + function nextTokenIsIdentifierOnSameLine() { nextToken(); - if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.expression = parseAssignmentExpression(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(166 /* YieldExpression */); + nextToken(); + if (!scanner.hasPrecedingLineBreak() && (token === 35 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } else { @@ -3630,346 +4352,411 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(31 /* EqualsGreaterThanToken */); - var parameter = createNode(123 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(157 /* ArrowFunction */, identifier.pos); + var parameter = createNode(124 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - var parameters = []; - parameters.push(parameter); - parameters.pos = parameter.pos; - parameters.end = parameter.end; - var signature = { parameters: parameters }; - return parseArrowExpressionTail(identifier.pos, signature); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + parseExpected(32 /* EqualsGreaterThanToken */); + node.body = parseArrowFunctionExpressionBody(); + return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0 /* False */) { return undefined; } - var pos = getNodePos(); - if (triState === 1 /* True */) { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { - return parseArrowExpressionTail(pos, sig); - } - else { - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode()); - } - } - var sig = tryParseSignatureIfArrowOrBraceFollows(); - if (sig) { - parseExpected(31 /* EqualsGreaterThanToken */); - return parseArrowExpressionTail(pos, sig); - } - else { + var arrowFunction = triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpressionHead(true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { return undefined; } + if (parseExpected(32 /* EqualsGreaterThanToken */) || token === 14 /* OpenBraceToken */) { + arrowFunction.body = parseArrowFunctionExpressionBody(); + } + else { + arrowFunction.body = parseIdentifier(); + } + return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return lookAhead(function () { - var first = token; - var second = nextToken(); - if (first === 15 /* OpenParenToken */) { - if (second === 16 /* CloseParenToken */) { - var third = nextToken(); - switch (third) { - case 31 /* EqualsGreaterThanToken */: - case 50 /* ColonToken */: - case 13 /* OpenBraceToken */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - if (second === 20 /* DotDotDotToken */) { - return 1 /* True */; - } - if (!isIdentifier()) { - return 0 /* False */; - } - if (nextToken() === 50 /* ColonToken */) { - return 1 /* True */; - } - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 23 /* LessThanToken */); - if (!isIdentifier()) { - return 0 /* False */; - } - return 2 /* Unknown */; - } - }); + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 31 /* EqualsGreaterThanToken */) { + if (token === 32 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } - function tryParseSignatureIfArrowOrBraceFollows() { - return tryParse(function () { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { - return sig; + function isParenthesizedArrowFunctionExpressionWorker() { + var first = token; + var second = nextToken(); + if (first === 16 /* OpenParenToken */) { + if (second === 17 /* CloseParenToken */) { + var third = nextToken(); + switch (third) { + case 32 /* EqualsGreaterThanToken */: + case 51 /* ColonToken */: + case 14 /* OpenBraceToken */: + return 1 /* True */; + default: + return 0 /* False */; + } } - return undefined; - }); - } - function parseArrowExpressionTail(pos, sig) { - var body; - if (token === 13 /* OpenBraceToken */) { - body = parseFunctionBlock(false, false); - } - else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { - body = parseFunctionBlock(false, true); + if (second === 21 /* DotDotDotToken */) { + return 1 /* True */; + } + if (!isIdentifier()) { + return 0 /* False */; + } + if (nextToken() === 51 /* ColonToken */) { + return 1 /* True */; + } + return 2 /* Unknown */; } else { - body = parseAssignmentExpression(); + ts.Debug.assert(first === 24 /* LessThanToken */); + if (!isIdentifier()) { + return 0 /* False */; + } + return 2 /* Unknown */; } - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body); } - function parseConditionalExpression() { - var expr = parseBinaryOperators(parseUnaryExpression(), 0); - while (parseOptional(49 /* QuestionToken */)) { - var node = createNode(157 /* ConditionalExpression */, expr.pos); - node.condition = expr; - node.whenTrue = allowInAnd(parseAssignmentExpression); - parseExpected(50 /* ColonToken */); - node.whenFalse = parseAssignmentExpression(); - expr = finishNode(node); + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(157 /* ArrowFunction */); + fillSignature(51 /* ColonToken */, false, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; } - return expr; + if (!allowAmbiguity && token !== 32 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + return undefined; + } + return node; } - function parseBinaryOperators(expr, minPrecedence) { + function parseArrowFunctionExpressionBody() { + if (token === 14 /* OpenBraceToken */) { + return parseFunctionBlock(false, false); + } + if (isStatement(true) && !isStartOfExpressionStatement() && token !== 82 /* FunctionKeyword */) { + return parseFunctionBlock(false, true); + } + return parseAssignmentExpressionOrHigher(); + } + function parseConditionalExpressionRest(leftOperand) { + if (!parseOptional(50 /* QuestionToken */)) { + return leftOperand; + } + var node = createNode(164 /* ConditionalExpression */, leftOperand.pos); + node.condition = leftOperand; + node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(51 /* ColonToken */); + node.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); - var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) { - var operator = token; - nextToken(); - expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); - continue; + var newPrecedence = getBinaryOperatorPrecedence(); + if (newPrecedence <= precedence) { + break; } - return expr; + if (token === 85 /* InKeyword */ && inDisallowInContext()) { + break; + } + var operator = token; + nextToken(); + leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); } + return leftOperand; } - function getOperatorPrecedence() { + function isBinaryOperator() { + if (inDisallowInContext() && token === 85 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { switch (token) { - case 48 /* BarBarToken */: + case 49 /* BarBarToken */: return 1; - case 47 /* AmpersandAmpersandToken */: + case 48 /* AmpersandAmpersandToken */: return 2; - case 43 /* BarToken */: + case 44 /* BarToken */: return 3; - case 44 /* CaretToken */: + case 45 /* CaretToken */: return 4; - case 42 /* AmpersandToken */: + case 43 /* AmpersandToken */: return 5; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: + case 28 /* EqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: return 6; - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: - case 85 /* InstanceOfKeyword */: - case 84 /* InKeyword */: + case 24 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 26 /* LessThanEqualsToken */: + case 27 /* GreaterThanEqualsToken */: + case 86 /* InstanceOfKeyword */: + case 85 /* InKeyword */: return 7; - case 39 /* LessThanLessThanToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: + case 40 /* LessThanLessThanToken */: + case 41 /* GreaterThanGreaterThanToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 32 /* PlusToken */: - case 33 /* MinusToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: return 9; - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: return 10; } - return undefined; + return -1; } function makeBinaryExpression(left, operator, right) { - var node = createNode(156 /* BinaryExpression */, left.pos); + var node = createNode(163 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; return finishNode(node); } - function parseUnaryExpression() { - var pos = getNodePos(); + function parsePrefixUnaryExpression() { + var node = createNode(161 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(158 /* DeleteExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(159 /* TypeOfExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(160 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { switch (token) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - var operator = token; - nextToken(); - return makeUnaryExpression(154 /* PrefixOperator */, pos, operator, parseUnaryExpression()); - case 23 /* LessThanToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: + case 46 /* ExclamationToken */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: + return parsePrefixUnaryExpression(); + case 73 /* DeleteKeyword */: + return parseDeleteExpression(); + case 96 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 98 /* VoidKeyword */: + return parseVoidExpression(); + case 24 /* LessThanToken */: return parseTypeAssertion(); + default: + return parsePostfixExpressionOrHigher(); } - var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; - if (illegalUsageOfSuperKeyword) { - error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - } - var expr = parseCallAndAccess(primaryExpression, false); - ts.Debug.assert(isLeftHandSideExpression(expr)); - if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var operator = token; + } + function parsePostfixExpressionOrHigher() { + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(isLeftHandSideExpression(expression)); + if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(162 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; nextToken(); - expr = makeUnaryExpression(155 /* PostfixOperator */, expr.pos, operator, expr); + return finishNode(node); } - return expr; + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 90 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + return expression; + } + var node = createNode(149 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + parseExpected(20 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); } function parseTypeAssertion() { - var node = createNode(150 /* TypeAssertion */); - parseExpected(23 /* LessThanToken */); + var node = createNode(154 /* TypeAssertionExpression */); + parseExpected(24 /* LessThanToken */); node.type = parseType(); - parseExpected(24 /* GreaterThanToken */); - node.operand = parseUnaryExpression(); + parseExpected(25 /* GreaterThanToken */); + node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function makeUnaryExpression(kind, pos, operator, operand) { - var node = createNode(kind, pos); - node.operator = operator; - node.operand = operand; - return finishNode(node); - } - function parseCallAndAccess(expr, inNewExpression) { + function parseMemberExpressionRest(expression) { while (true) { var dotOrBracketStart = scanner.getTokenPos(); - if (parseOptional(19 /* DotToken */)) { - var propertyAccess = createNode(145 /* PropertyAccess */, expr.pos); - var id; - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord); - }); - if (matchesPattern) { - errorAtPos(dotOrBracketStart + 1, 0, ts.Diagnostics.Identifier_expected); - id = createMissingNode(); - } - } - propertyAccess.left = expr; - propertyAccess.right = id || parseIdentifierName(); - expr = finishNode(propertyAccess); + if (parseOptional(20 /* DotToken */)) { + var propertyAccess = createNode(149 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); continue; } - if (parseOptional(17 /* OpenBracketToken */)) { - var indexedAccess = createNode(146 /* IndexedAccess */, expr.pos); - indexedAccess.object = expr; - if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { - indexedAccess.index = createMissingNode(); - } - else { - indexedAccess.index = allowInAnd(parseExpression); - if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) { - var literal = indexedAccess.index; + if (parseOptional(18 /* OpenBracketToken */)) { + var indexedAccess = createNode(150 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + if (token !== 19 /* CloseBracketToken */) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } - parseExpected(18 /* CloseBracketToken */); } - expr = finishNode(indexedAccess); + parseExpected(19 /* CloseBracketToken */); + expression = finishNode(indexedAccess); continue; } - if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(147 /* CallExpression */, expr.pos); - callExpr.func = expr; - if (token === 23 /* LessThanToken */) { - if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) - return expr; - } - else { - parseExpected(15 /* OpenParenToken */); - } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); - expr = finishNode(callExpr); + if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { + var tagExpression = createNode(153 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + expression = finishNode(tagExpression); continue; } - if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { - var tagExpression = createNode(149 /* TaggedTemplateExpression */, expr.pos); - tagExpression.tag = expr; - tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); - expr = finishNode(tagExpression); - continue; - } - return expr; + return expression; } } - function parseTypeArgumentsAndOpenParen() { - var result = parseTypeArguments(); - parseExpected(15 /* OpenParenToken */); + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 24 /* LessThanToken */) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(151 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 16 /* OpenParenToken */) { + var callExpr = createNode(151 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(16 /* OpenParenToken */); + var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(17 /* CloseParenToken */); return result; } - function parseTypeArguments() { - return parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); - } - function parseSingleTypeArgument() { - if (token === 22 /* CommaToken */) { - return createNode(120 /* Missing */); + function parseTypeArgumentsInExpression() { + if (!parseOptional(24 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + if (!parseExpected(25 /* GreaterThanToken */)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 16 /* OpenParenToken */: + case 20 /* DotToken */: + case 17 /* CloseParenToken */: + case 19 /* CloseBracketToken */: + case 51 /* ColonToken */: + case 22 /* SemicolonToken */: + case 23 /* CommaToken */: + case 50 /* QuestionToken */: + case 28 /* EqualsEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: + case 48 /* AmpersandAmpersandToken */: + case 49 /* BarBarToken */: + case 45 /* CaretToken */: + case 43 /* AmpersandToken */: + case 44 /* BarToken */: + case 15 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + return true; + default: + return false; } - return parseType(); } function parsePrimaryExpression() { switch (token) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + case 88 /* NullKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: return parseTokenNode(); - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 15 /* OpenParenToken */: - return parseParenExpression(); - case 17 /* OpenBracketToken */: - return parseArrayLiteral(); - case 13 /* OpenBraceToken */: - return parseObjectLiteral(); - case 81 /* FunctionKeyword */: + case 16 /* OpenParenToken */: + return parseParenthesizedExpression(); + case 18 /* OpenBracketToken */: + return parseArrayLiteralExpression(); + case 14 /* OpenBraceToken */: + return parseObjectLiteralExpression(); + case 82 /* FunctionKeyword */: return parseFunctionExpression(); - case 86 /* NewKeyword */: + case 87 /* NewKeyword */: return parseNewExpression(); - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - if (reScanSlashToken() === 8 /* RegularExpressionLiteral */) { + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 10 /* TemplateHead */: + case 11 /* TemplateHead */: return parseTemplateExpression(); - default: - if (isIdentifier()) { - return parseIdentifier(); - } } - error(ts.Diagnostics.Expression_expected); - return createMissingNode(); + return parseIdentifier(ts.Diagnostics.Expression_expected); } - function parseParenExpression() { - var node = createNode(151 /* ParenExpression */); - parseExpected(15 /* OpenParenToken */); + function parseParenthesizedExpression() { + var node = createNode(155 /* ParenthesizedExpression */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression() { - return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression(); + return token === 23 /* CommaToken */ ? createNode(167 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArrayLiteralElement() { return parseAssignmentExpressionOrOmittedExpression(); @@ -3977,104 +4764,82 @@ var ts; function parseArgumentExpression() { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral() { - var node = createNode(141 /* ArrayLiteral */); - parseExpected(17 /* OpenBracketToken */); + function parseArrayLiteralExpression() { + var node = createNode(147 /* ArrayLiteralExpression */); + parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; - node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement); - parseExpected(18 /* CloseBracketToken */); + node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArrayLiteralElement); + parseExpected(19 /* CloseBracketToken */); return finishNode(node); } - function parsePropertyAssignment() { - var nodePos = scanner.getStartPos(); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var initialToken = token; + if (parseContextualModifier(114 /* GetKeyword */) || parseContextualModifier(118 /* SetKeyword */)) { + var kind = initialToken === 114 /* GetKeyword */ ? 130 /* GetAccessor */ : 131 /* SetAccessor */; + return parseAccessorDeclaration(kind, fullStart, undefined); + } + var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var node; - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body); - return finishNode(node); + if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return parseMethodDeclaration(fullStart, undefined, asteriskToken, propertyName, undefined, true); } - var flags = 0; - if (token === 49 /* QuestionToken */) { - flags |= 4 /* QuestionMark */; - nextToken(); - } - if ((token === 22 /* CommaToken */ || token === 14 /* CloseBraceToken */) && tokenIsIdentifier) { - node = createNode(144 /* ShorthandPropertyAssignment */, nodePos); - node.name = propertyName; + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(205 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + return finishNode(shorthandDeclaration); } else { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - parseExpected(50 /* ColonToken */); - node.initializer = allowInAnd(parseAssignmentExpression); + var propertyAssignment = createNode(204 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(51 /* ColonToken */); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); } - node.flags = flags; - return finishNode(node); } - function parseObjectLiteralMember() { - var initialPos = getNodePos(); - var initialToken = token; - if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { - var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; - return parseMemberAccessorDeclaration(kind, initialPos, undefined); - } - return parsePropertyAssignment(); - } - function parseObjectLiteral() { - var node = createNode(142 /* ObjectLiteral */); - parseExpected(13 /* OpenBraceToken */); + function parseObjectLiteralExpression() { + var node = createNode(148 /* ObjectLiteralExpression */); + parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember); - parseExpected(14 /* CloseBraceToken */); + node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement); + parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - var pos = getNodePos(); - parseExpected(81 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body); + var node = createNode(156 /* FunctionExpression */); + parseExpected(82 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); + fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); + node.body = parseFunctionBlock(!!node.asteriskToken, false); + return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } - function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) { - var node = createNode(kind, pos); - node.asteriskToken = asteriskToken; - node.name = name; - node.typeParameters = sig.typeParameters; - node.parameters = sig.parameters; - node.type = sig.type; - node.body = body; - return finishNode(node); - } function parseNewExpression() { - var node = createNode(148 /* NewExpression */); - parseExpected(86 /* NewKeyword */); - node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); + var node = createNode(152 /* NewExpression */); + parseExpected(87 /* NewKeyword */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 16 /* OpenParenToken */) { + node.arguments = parseArgumentList(); } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(162 /* Block */); - if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { + function parseBlock(kind, ignoreMissingOpenBrace, checkForStrictMode) { + var node = createNode(kind); + if (parseExpected(14 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -4084,58 +4849,57 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 187 /* FunctionBlock */; + var block = parseBlock(169 /* Block */, ignoreMissingOpenBrace, true); setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(164 /* EmptyStatement */); - parseExpected(21 /* SemicolonToken */); + var node = createNode(171 /* EmptyStatement */); + parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(166 /* IfStatement */); - parseExpected(82 /* IfKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(173 /* IfStatement */); + parseExpected(83 /* IfKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(75 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(167 /* DoStatement */); - parseExpected(73 /* DoKeyword */); + var node = createNode(174 /* DoStatement */); + parseExpected(74 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); + parseExpected(99 /* WhileKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseOptional(21 /* SemicolonToken */); + parseExpected(17 /* CloseParenToken */); + parseOptional(22 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(168 /* WhileStatement */); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(175 /* WhileStatement */); + parseExpected(99 /* WhileKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInStatement() { var pos = getNodePos(); - parseExpected(80 /* ForKeyword */); - parseExpected(15 /* OpenParenToken */); - if (token !== 21 /* SemicolonToken */) { - if (parseOptional(96 /* VarKeyword */)) { + parseExpected(81 /* ForKeyword */); + parseExpected(16 /* OpenParenToken */); + if (token !== 22 /* SemicolonToken */) { + if (parseOptional(97 /* VarKeyword */)) { var declarations = disallowInAnd(parseVariableDeclarationList); } - else if (parseOptional(102 /* LetKeyword */)) { + else if (parseOptional(103 /* LetKeyword */)) { var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 2048 /* Let */); } - else if (parseOptional(68 /* ConstKeyword */)) { + else if (parseOptional(69 /* ConstKeyword */)) { var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 4096 /* Const */); } else { @@ -4143,8 +4907,8 @@ var ts; } } var forOrForInStatement; - if (parseOptional(84 /* InKeyword */)) { - var forInStatement = createNode(170 /* ForInStatement */, pos); + if (parseOptional(85 /* InKeyword */)) { + var forInStatement = createNode(177 /* ForInStatement */, pos); if (declarations) { forInStatement.declarations = declarations; } @@ -4152,26 +4916,26 @@ var ts; forInStatement.variable = varOrInit; } forInStatement.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); forOrForInStatement = forInStatement; } else { - var forStatement = createNode(169 /* ForStatement */, pos); + var forStatement = createNode(176 /* ForStatement */, pos); if (declarations) { forStatement.declarations = declarations; } if (varOrInit) { forStatement.initializer = varOrInit; } - parseExpected(21 /* SemicolonToken */); - if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) { + parseExpected(22 /* SemicolonToken */); + if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(21 /* SemicolonToken */); - if (token !== 16 /* CloseParenToken */) { + parseExpected(22 /* SemicolonToken */); + if (token !== 17 /* CloseParenToken */) { forStatement.iterator = allowInAnd(parseExpression); } - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); forOrForInStatement = forStatement; } forOrForInStatement.statement = parseStatement(); @@ -4179,7 +4943,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); + parseExpected(kind === 179 /* BreakStatement */ ? 65 /* BreakKeyword */ : 70 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -4187,8 +4951,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(173 /* ReturnStatement */); - parseExpected(88 /* ReturnKeyword */); + var node = createNode(180 /* ReturnStatement */); + parseExpected(89 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -4196,235 +4960,283 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(174 /* WithStatement */); - parseExpected(99 /* WithKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(181 /* WithStatement */); + parseExpected(100 /* WithKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); + parseExpected(17 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(176 /* CaseClause */); - parseExpected(65 /* CaseKeyword */); + var node = createNode(200 /* CaseClause */); + parseExpected(66 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(50 /* ColonToken */); + parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(177 /* DefaultClause */); - parseExpected(71 /* DefaultKeyword */); - parseExpected(50 /* ColonToken */); + var node = createNode(201 /* DefaultClause */); + parseExpected(72 /* DefaultKeyword */); + parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 66 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(175 /* SwitchStatement */); - parseExpected(90 /* SwitchKeyword */); - parseExpected(15 /* OpenParenToken */); + var node = createNode(182 /* SwitchStatement */); + parseExpected(91 /* SwitchKeyword */); + parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseExpected(13 /* OpenBraceToken */); + parseExpected(17 /* CloseParenToken */); + parseExpected(14 /* OpenBraceToken */); node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseThrowStatement() { - var node = createNode(179 /* ThrowStatement */); - parseExpected(92 /* ThrowKeyword */); - if (scanner.hasPrecedingLineBreak()) { - error(ts.Diagnostics.Line_break_not_permitted_here); - } - node.expression = allowInAnd(parseExpression); + var node = createNode(184 /* ThrowStatement */); + parseExpected(93 /* ThrowKeyword */); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(180 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */); - if (token === 66 /* CatchKeyword */) { - node.catchBlock = parseCatchBlock(); - } - if (token === 79 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */); - } - if (!(node.catchBlock || node.finallyBlock)) { - error(ts.Diagnostics.catch_or_finally_expected); - } + var node = createNode(185 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(95 /* TryKeyword */); + node.catchClause = token === 67 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.finallyBlock = !node.catchClause || token === 80 /* FinallyKeyword */ ? parseTokenAndBlock(80 /* FinallyKeyword */) : undefined; return finishNode(node); } - function parseTokenAndBlock(token, kind) { + function parseTokenAndBlock(token) { var pos = getNodePos(); parseExpected(token); - var result = parseBlock(false, false); - result.kind = kind; + var result = parseBlock(token === 95 /* TryKeyword */ ? 186 /* TryBlock */ : 187 /* FinallyBlock */, false, false); result.pos = pos; return result; } - function parseCatchBlock() { - var pos = getNodePos(); - parseExpected(66 /* CatchKeyword */); - parseExpected(15 /* OpenParenToken */); - var variable = parseIdentifier(); - var typeAnnotation = parseTypeAnnotation(); - parseExpected(16 /* CloseParenToken */); - var result = parseBlock(false, false); - result.kind = 182 /* CatchBlock */; - result.pos = pos; - result.variable = variable; - result.type = typeAnnotation; - return result; + function parseCatchClause() { + var result = createNode(203 /* CatchClause */); + parseExpected(67 /* CatchKeyword */); + parseExpected(16 /* OpenParenToken */); + result.name = parseIdentifier(); + result.type = parseTypeAnnotation(); + parseExpected(17 /* CloseParenToken */); + result.block = parseBlock(169 /* Block */, false, false); + return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(184 /* DebuggerStatement */); - parseExpected(70 /* DebuggerKeyword */); + var node = createNode(188 /* DebuggerStatement */); + parseExpected(71 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } - function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); - } - function parseLabeledStatement() { - var node = createNode(178 /* LabeledStatement */); - node.label = parseIdentifier(); - parseExpected(50 /* ColonToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseExpressionStatement() { - var node = createNode(165 /* ExpressionStatement */); - node.expression = allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); + function parseExpressionOrLabeledStatement() { + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 64 /* Identifier */ && parseOptional(51 /* ColonToken */)) { + var labeledStatement = createNode(183 /* LabeledStatement */, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(172 /* ExpressionStatement */, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } } function isStatement(inErrorRecovery) { switch (token) { - case 21 /* SemicolonToken */: + case 22 /* SemicolonToken */: return !inErrorRecovery; - case 13 /* OpenBraceToken */: - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 81 /* FunctionKeyword */: - case 82 /* IfKeyword */: - case 73 /* DoKeyword */: - case 98 /* WhileKeyword */: - case 80 /* ForKeyword */: - case 69 /* ContinueKeyword */: - case 64 /* BreakKeyword */: - case 88 /* ReturnKeyword */: - case 99 /* WithKeyword */: - case 90 /* SwitchKeyword */: - case 92 /* ThrowKeyword */: - case 94 /* TryKeyword */: - case 70 /* DebuggerKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: + case 14 /* OpenBraceToken */: + case 97 /* VarKeyword */: + case 103 /* LetKeyword */: + case 82 /* FunctionKeyword */: + case 83 /* IfKeyword */: + case 74 /* DoKeyword */: + case 99 /* WhileKeyword */: + case 81 /* ForKeyword */: + case 70 /* ContinueKeyword */: + case 65 /* BreakKeyword */: + case 89 /* ReturnKeyword */: + case 100 /* WithKeyword */: + case 91 /* SwitchKeyword */: + case 93 /* ThrowKeyword */: + case 95 /* TryKeyword */: + case 71 /* DebuggerKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: return true; - case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + case 69 /* ConstKeyword */: + var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; - case 101 /* InterfaceKeyword */: - case 67 /* ClassKeyword */: - case 114 /* ModuleKeyword */: - case 75 /* EnumKeyword */: - case 119 /* TypeKeyword */: + case 102 /* InterfaceKeyword */: + case 68 /* ClassKeyword */: + case 115 /* ModuleKeyword */: + case 76 /* EnumKeyword */: + case 120 /* TypeKeyword */: if (isDeclarationStart()) { return false; } - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } default: return isStartOfExpression(); } } + function nextTokenIsEnumKeyword() { + nextToken(); + return token === 76 /* EnumKeyword */; + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + } function parseStatement() { switch (token) { - case 13 /* OpenBraceToken */: - return parseBlock(false, false); - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 68 /* ConstKeyword */: + case 14 /* OpenBraceToken */: + return parseBlock(169 /* Block */, false, false); + case 97 /* VarKeyword */: + case 69 /* ConstKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined); - case 81 /* FunctionKeyword */: + case 82 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), undefined); - case 21 /* SemicolonToken */: + case 22 /* SemicolonToken */: return parseEmptyStatement(); - case 82 /* IfKeyword */: + case 83 /* IfKeyword */: return parseIfStatement(); - case 73 /* DoKeyword */: + case 74 /* DoKeyword */: return parseDoStatement(); - case 98 /* WhileKeyword */: + case 99 /* WhileKeyword */: return parseWhileStatement(); - case 80 /* ForKeyword */: + case 81 /* ForKeyword */: return parseForOrForInStatement(); - case 69 /* ContinueKeyword */: - return parseBreakOrContinueStatement(171 /* ContinueStatement */); - case 64 /* BreakKeyword */: - return parseBreakOrContinueStatement(172 /* BreakStatement */); - case 88 /* ReturnKeyword */: + case 70 /* ContinueKeyword */: + return parseBreakOrContinueStatement(178 /* ContinueStatement */); + case 65 /* BreakKeyword */: + return parseBreakOrContinueStatement(179 /* BreakStatement */); + case 89 /* ReturnKeyword */: return parseReturnStatement(); - case 99 /* WithKeyword */: + case 100 /* WithKeyword */: return parseWithStatement(); - case 90 /* SwitchKeyword */: + case 91 /* SwitchKeyword */: return parseSwitchStatement(); - case 92 /* ThrowKeyword */: + case 93 /* ThrowKeyword */: return parseThrowStatement(); - case 94 /* TryKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: + case 95 /* TryKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: return parseTryStatement(); - case 70 /* DebuggerKeyword */: + case 71 /* DebuggerKeyword */: return parseDebuggerStatement(); + case 103 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), undefined); + } default: - return isLabel() ? parseLabeledStatement() : parseExpressionStatement(); + return parseExpressionOrLabeledStatement(); } } function parseFunctionBlockOrSemicolon(isGenerator) { - if (token === 13 /* OpenBraceToken */) { + if (token === 14 /* OpenBraceToken */) { return parseFunctionBlock(isGenerator, false); } - if (canParseSemicolon()) { - parseSemicolon(); - return undefined; + parseSemicolon(ts.Diagnostics.or_expected); + return undefined; + } + function parseBindingElement(context) { + if (context === 11 /* ArrayBindingElements */ && token === 23 /* CommaToken */) { + return createNode(167 /* OmittedExpression */); } - error(ts.Diagnostics.Block_or_expected); + var node = createNode(146 /* BindingElement */); + if (context === 10 /* ObjectBindingElements */) { + var id = parsePropertyName(); + if (id.kind === 64 /* Identifier */ && token !== 51 /* ColonToken */) { + node.name = id; + } + else { + parseExpected(51 /* ColonToken */); + node.propertyName = id; + node.name = parseIdentifierOrPattern(); + } + } + else { + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseInitializer(false); + return finishNode(node); + } + function parseBindingList(context) { + return parseDelimitedList(context, function () { return parseBindingElement(context); }); + } + function parseObjectBindingPattern() { + var node = createNode(144 /* ObjectBindingPattern */); + parseExpected(14 /* OpenBraceToken */); + node.elements = parseBindingList(10 /* ObjectBindingElements */); + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(145 /* ArrayBindingPattern */); + parseExpected(18 /* OpenBracketToken */); + node.elements = parseBindingList(11 /* ArrayBindingElements */); + parseExpected(19 /* CloseBracketToken */); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 18 /* OpenBracketToken */) { + return parseArrayBindingPattern(); + } + if (token === 14 /* OpenBraceToken */) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(185 /* VariableDeclaration */); - node.name = parseIdentifier(); + var node = createNode(189 /* VariableDeclaration */); + node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); node.initializer = parseInitializer(false); return finishNode(node); } - function setFlag(array, flag) { - for (var i = 0, n = array.length; i < n; i++) { - array[i].flags |= flag; + function setFlag(nodes, flag) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + node.flags |= flag; + if (node.name && ts.isBindingPattern(node.name)) { + setFlag(node.name.elements, flag); + } } - return array; + return nodes; } function parseVariableDeclarationList() { return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); } function parseVariableStatement(fullStart, modifiers) { - var node = createNode(163 /* VariableStatement */, fullStart); + var node = createNode(170 /* VariableStatement */, fullStart); setModifiers(node, modifiers); - if (token === 102 /* LetKeyword */) { + if (token === 103 /* LetKeyword */) { node.flags |= 2048 /* Let */; } - else if (token === 68 /* ConstKeyword */) { + else if (token === 69 /* ConstKeyword */) { node.flags |= 4096 /* Const */; } else { - ts.Debug.assert(token === 96 /* VarKeyword */); + ts.Debug.assert(token === 97 /* VarKeyword */); } nextToken(); node.declarations = allowInAnd(parseVariableDeclarationList); @@ -4433,89 +5245,88 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(186 /* FunctionDeclaration */, fullStart); + var node = createNode(190 /* FunctionDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(81 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + parseExpected(82 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = parseIdentifier(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node); + fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken); return finishNode(node); } function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(126 /* Constructor */, pos); + var node = createNode(129 /* Constructor */, pos); setModifiers(node, modifiers); - parseExpected(111 /* ConstructorKeyword */); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + parseExpected(112 /* ConstructorKeyword */); + fillSignature(51 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } - function parsePropertyMemberDeclaration(fullStart, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, requireBlock) { + var method = createNode(128 /* MethodDeclaration */, fullStart); + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + fillSignature(51 /* ColonToken */, !!asteriskToken, false, method); + method.body = requireBlock ? parseFunctionBlock(!!asteriskToken, false) : parseFunctionBlockOrSemicolon(!!asteriskToken); + return finishNode(method); + } + function parsePropertyOrMethodDeclaration(fullStart, modifiers) { + var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); var name = parsePropertyName(); - if (parseOptional(49 /* QuestionToken */)) { - flags |= 4 /* QuestionMark */; - } - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); - setModifiers(method, modifiers); - if (flags) { - method.flags = flags; - } - method.asteriskToken = asteriskToken; - method.name = name; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken); - return finishNode(method); + var questionToken = parseOptionalToken(50 /* QuestionToken */); + if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, false); } else { - var property = createNode(124 /* Property */, fullStart); + var property = createNode(126 /* PropertyDeclaration */, fullStart); setModifiers(property, modifiers); - if (flags) { - property.flags = flags; - } property.name = name; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(function () { return parseInitializer(false); }); + property.initializer = allowInAnd(parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } } - function parseMemberAccessorDeclaration(kind, fullStart, modifiers) { + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, modifiers) { var node = createNode(kind, fullStart); setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(51 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } function isClassMemberStart() { var idToken; - while (isModifier(token)) { + while (ts.isModifier(token)) { idToken = token; nextToken(); } - if (token === 34 /* AsteriskToken */) { + if (token === 35 /* AsteriskToken */) { return true; } - if (isPropertyName()) { + if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 17 /* OpenBracketToken */) { + if (token === 18 /* OpenBracketToken */) { return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 118 /* SetKeyword */ || idToken === 114 /* GetKeyword */) { return true; } switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 50 /* ColonToken */: - case 51 /* EqualsToken */: - case 49 /* QuestionToken */: + case 16 /* OpenParenToken */: + case 24 /* LessThanToken */: + case 51 /* ColonToken */: + case 52 /* EqualsToken */: + case 50 /* QuestionToken */: return true; default: return canParseSemicolon(); @@ -4527,246 +5338,271 @@ var ts; var flags = 0; var modifiers; while (true) { - var modifierStart = scanner.getTokenPos(); + var modifierStart = scanner.getStartPos(); var modifierKind = token; if (!parseAnyContextualModifier()) { break; } if (!modifiers) { modifiers = []; + modifiers.pos = modifierStart; } flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } if (modifiers) { modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); } return modifiers; } - function parseClassMemberDeclaration() { + function parseClassElement() { var fullStart = getNodePos(); var modifiers = parseModifiers(); - if (parseContextualModifier(113 /* GetKeyword */)) { - return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); + if (parseContextualModifier(114 /* GetKeyword */)) { + return parseAccessorDeclaration(130 /* GetAccessor */, fullStart, modifiers); } - if (parseContextualModifier(117 /* SetKeyword */)) { - return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); + if (parseContextualModifier(118 /* SetKeyword */)) { + return parseAccessorDeclaration(131 /* SetAccessor */, fullStart, modifiers); } - if (token === 111 /* ConstructorKeyword */) { + if (token === 112 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) { - return parsePropertyMemberDeclaration(fullStart, modifiers); + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, modifiers); } - if (token === 17 /* OpenBracketToken */) { - return parseIndexSignatureMember(fullStart, modifiers); + if (isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || token === 35 /* AsteriskToken */ || token === 18 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, modifiers); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(188 /* ClassDeclaration */, fullStart); + var node = createNode(191 /* ClassDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(67 /* ClassKeyword */); + parseExpected(68 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType(); - if (parseOptional(100 /* ImplementsKeyword */)) { - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - if (parseExpected(13 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(true); + if (parseExpected(14 /* OpenBraceToken */)) { node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers(); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.members = createMissingList(); } return finishNode(node); } - function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); + } + return undefined; } - function parseClassBaseType() { - return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + function parseHeritageClausesWorker() { + return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */) { + var node = createNode(202 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(8 /* TypeReferences */, parseTypeReference); + return finishNode(node); + } + return undefined; + } + function isHeritageClause() { + return token === 78 /* ExtendsKeyword */ || token === 101 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(189 /* InterfaceDeclaration */, fullStart); + var node = createNode(192 /* InterfaceDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(101 /* InterfaceKeyword */); + parseExpected(102 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - if (parseOptional(77 /* ExtendsKeyword */)) { - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - node.members = parseObjectType(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(190 /* TypeAliasDeclaration */, fullStart); + var node = createNode(193 /* TypeAliasDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(119 /* TypeKeyword */); + parseExpected(120 /* TypeKeyword */); node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); + parseExpected(52 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(196 /* EnumMember */, scanner.getStartPos()); + var node = createNode(206 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(function () { return parseInitializer(false); }); + node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseAndCheckEnumDeclaration(fullStart, flags) { - var node = createNode(191 /* EnumDeclaration */, fullStart); - node.flags = flags; - if (flags & 4096 /* Const */) { - parseExpected(68 /* ConstKeyword */); - } - parseExpected(75 /* EnumKeyword */); + function parseEnumDeclaration(fullStart, modifiers) { + var node = createNode(194 /* EnumDeclaration */, fullStart); + setModifiers(node, modifiers); + parseExpected(76 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(13 /* OpenBraceToken */)) { + if (parseExpected(14 /* OpenBraceToken */)) { node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.members = createMissingList(); } return finishNode(node); } - function parseModuleBody() { - var node = createNode(193 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(13 /* OpenBraceToken */)) { + function parseModuleBlock() { + var node = createNode(196 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); - parseExpected(14 /* CloseBraceToken */); + parseExpected(15 /* CloseBraceToken */); } else { node.statements = createMissingList(); } return finishNode(node); } - function parseInternalModuleTail(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; + function parseInternalModuleTail(fullStart, modifiers, flags) { + var node = createNode(195 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody(); + node.body = parseOptional(20 /* DotToken */) ? parseInternalModuleTail(getNodePos(), undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; - node.name = parseStringLiteral(); - node.body = parseModuleBody(); + function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { + var node = createNode(195 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, flags) { - parseExpected(114 /* ModuleKeyword */); - return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags); + function parseModuleDeclaration(fullStart, modifiers) { + parseExpected(115 /* ModuleKeyword */); + return token === 8 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + } + function isExternalModuleReference() { + return token === 116 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 16 /* OpenParenToken */; } function parseImportDeclaration(fullStart, modifiers) { - var node = createNode(194 /* ImportDeclaration */, fullStart); + var node = createNode(197 /* ImportDeclaration */, fullStart); setModifiers(node, modifiers); - parseExpected(83 /* ImportKeyword */); + parseExpected(84 /* ImportKeyword */); node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); - var entityName = parseEntityName(false); - if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { - node.externalModuleName = parseStringLiteral(); - parseExpected(16 /* CloseParenToken */); - } - else { - node.entityName = entityName; - } + parseExpected(52 /* EqualsToken */); + node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } + function parseModuleReference() { + return isExternalModuleReference() ? parseExternalModuleReference() : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(199 /* ExternalModuleReference */); + parseExpected(116 /* RequireKeyword */); + parseExpected(16 /* OpenParenToken */); + node.expression = parseExpression(); + if (node.expression.kind === 8 /* StringLiteral */) { + internIdentifier(node.expression.text); + } + parseExpected(17 /* CloseParenToken */); + return finishNode(node); + } function parseExportAssignmentTail(fullStart, modifiers) { - var node = createNode(195 /* ExportAssignment */, fullStart); + var node = createNode(198 /* ExportAssignment */, fullStart); setModifiers(node, modifiers); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } + function isLetDeclaration() { + return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine); + } function isDeclarationStart() { switch (token) { - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 68 /* ConstKeyword */: - case 81 /* FunctionKeyword */: + case 97 /* VarKeyword */: + case 69 /* ConstKeyword */: + case 82 /* FunctionKeyword */: return true; - case 67 /* ClassKeyword */: - case 101 /* InterfaceKeyword */: - case 75 /* EnumKeyword */: - case 83 /* ImportKeyword */: - case 119 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); - case 114 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); - case 76 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); - case 112 /* DeclareKeyword */: - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - return lookAhead(function () { - nextToken(); - return isDeclarationStart(); - }); + case 103 /* LetKeyword */: + return isLetDeclaration(); + case 68 /* ClassKeyword */: + case 102 /* InterfaceKeyword */: + case 76 /* EnumKeyword */: + case 84 /* ImportKeyword */: + case 120 /* TypeKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeyword); + case 115 /* ModuleKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); + case 77 /* ExportKeyword */: + return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart); + case 113 /* DeclareKeyword */: + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: + case 108 /* StaticKeyword */: + return lookAhead(nextTokenIsDeclarationStart); } } + function isIdentifierOrKeyword() { + return token >= 64 /* Identifier */; + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function nextTokenIsIdentifierOrKeywordOrStringLiteral() { + nextToken(); + return isIdentifierOrKeyword() || token === 8 /* StringLiteral */; + } + function nextTokenIsEqualsTokenOrDeclarationStart() { + nextToken(); + return token === 52 /* EqualsToken */ || isDeclarationStart(); + } + function nextTokenIsDeclarationStart() { + nextToken(); + return isDeclarationStart(); + } function parseDeclaration() { var fullStart = getNodePos(); var modifiers = parseModifiers(); - if (token === 76 /* ExportKeyword */) { + if (token === 77 /* ExportKeyword */) { nextToken(); - if (parseOptional(51 /* EqualsToken */)) { + if (parseOptional(52 /* EqualsToken */)) { return parseExportAssignmentTail(fullStart, modifiers); } } - var flags = modifiers ? modifiers.flags : 0; - var result; switch (token) { - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - result = parseVariableStatement(fullStart, modifiers); - break; - case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); - if (isConstEnum) { - result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */); - } - else { - result = parseVariableStatement(fullStart, modifiers); - } - break; - case 81 /* FunctionKeyword */: - result = parseFunctionDeclaration(fullStart, modifiers); - break; - case 67 /* ClassKeyword */: - result = parseClassDeclaration(fullStart, modifiers); - break; - case 101 /* InterfaceKeyword */: - result = parseInterfaceDeclaration(fullStart, modifiers); - break; - case 119 /* TypeKeyword */: - result = parseTypeAliasDeclaration(fullStart, modifiers); - break; - case 75 /* EnumKeyword */: - result = parseAndCheckEnumDeclaration(fullStart, flags); - break; - case 114 /* ModuleKeyword */: - result = parseModuleDeclaration(fullStart, flags); - break; - case 83 /* ImportKeyword */: - result = parseImportDeclaration(fullStart, modifiers); - break; + case 97 /* VarKeyword */: + case 103 /* LetKeyword */: + case 69 /* ConstKeyword */: + return parseVariableStatement(fullStart, modifiers); + case 82 /* FunctionKeyword */: + return parseFunctionDeclaration(fullStart, modifiers); + case 68 /* ClassKeyword */: + return parseClassDeclaration(fullStart, modifiers); + case 102 /* InterfaceKeyword */: + return parseInterfaceDeclaration(fullStart, modifiers); + case 120 /* TypeKeyword */: + return parseTypeAliasDeclaration(fullStart, modifiers); + case 76 /* EnumKeyword */: + return parseEnumDeclaration(fullStart, modifiers); + case 115 /* ModuleKeyword */: + return parseModuleDeclaration(fullStart, modifiers); + case 84 /* ImportKeyword */: + return parseImportDeclaration(fullStart, modifiers); default: - error(ts.Diagnostics.Declaration_expected); + ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } - if (modifiers) { - result.modifiers = modifiers; - } - return result; } function isSourceElement(inErrorRecovery) { return isDeclarationStart() || isStatement(inErrorRecovery); @@ -4781,24 +5617,30 @@ var ts; return isDeclarationStart() ? parseDeclaration() : parseStatement(); } function processReferenceComments() { + var triviaScanner = ts.createScanner(languageVersion, false, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; - commentRanges = []; - token = scanner.scan(); - for (var i = 0; i < commentRanges.length; i++) { - var range = commentRanges[i]; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() }; var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { var fileReference = referencePathMatchResult.fileReference; - file.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnostic = referencePathMatchResult.diagnostic; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; if (fileReference) { referencedFiles.push(fileReference); } - if (diagnostic) { - errorAtPos(range.pos, range.end - range.pos, diagnostic); + if (diagnosticMessage) { + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); } } else { @@ -4806,7 +5648,7 @@ var ts; var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment); if (amdModuleNameMatchResult) { if (amdModuleName) { - errorAtPos(range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments); + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments)); } amdModuleName = amdModuleNameMatchResult[2]; } @@ -4817,91 +5659,59 @@ var ts; } } } - commentRanges = undefined; - return { - referencedFiles: referencedFiles, - amdDependencies: amdDependencies, - amdModuleName: amdModuleName - }; + sourceFile.referencedFiles = referencedFiles; + sourceFile.amdDependencies = amdDependencies; + sourceFile.amdModuleName = amdModuleName; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */ || node.kind === 198 /* ExportAssignment */ ? node : undefined; }); } var syntacticDiagnostics; function getSyntacticDiagnostics() { if (syntacticDiagnostics === undefined) { - if (file.parseDiagnostics.length > 0) { - syntacticDiagnostics = file.parseDiagnostics; + if (sourceFile.parseDiagnostics.length > 0) { + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); } else { - syntacticDiagnostics = file.grammarDiagnostics; - checkGrammar(sourceText, languageVersion, file); + checkGrammar(sourceText, languageVersion, sourceFile); + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); } } ts.Debug.assert(syntacticDiagnostics !== undefined); return syntacticDiagnostics; } - scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); - var rootNodeFlags = 0; - if (ts.fileExtensionIs(filename, ".d.ts")) { - rootNodeFlags = 1024 /* DeclarationFile */; - } - file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags); - file.filename = ts.normalizePath(filename); - file.text = sourceText; - file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - file.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - file.getLineStarts = getLineStarts; - file.getSyntacticDiagnostics = getSyntacticDiagnostics; - file.parseDiagnostics = []; - file.grammarDiagnostics = []; - file.semanticDiagnostics = []; - var referenceComments = processReferenceComments(); - file.referencedFiles = referenceComments.referencedFiles; - file.amdDependencies = referenceComments.amdDependencies; - file.amdModuleName = referenceComments.amdModuleName; - file.statements = parseList(0 /* SourceElements */, true, parseSourceElement); - file.externalModuleIndicator = getExternalModuleIndicator(); - file.nodeCount = nodeCount; - file.identifierCount = identifierCount; - file.version = version; - file.isOpen = isOpen; - file.languageVersion = languageVersion; - file.identifiers = identifiers; - return file; } ts.createSourceFile = createSourceFile; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 148 /* NewExpression */: - case 147 /* CallExpression */: - case 149 /* TaggedTemplateExpression */: - case 141 /* ArrayLiteral */: - case 151 /* ParenExpression */: - case 142 /* ObjectLiteral */: - case 152 /* FunctionExpression */: - case 63 /* Identifier */: - case 120 /* Missing */: - case 8 /* RegularExpressionLiteral */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 158 /* TemplateExpression */: - case 78 /* FalseKeyword */: - case 87 /* NullKeyword */: - case 91 /* ThisKeyword */: - case 93 /* TrueKeyword */: - case 89 /* SuperKeyword */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 152 /* NewExpression */: + case 151 /* CallExpression */: + case 153 /* TaggedTemplateExpression */: + case 147 /* ArrayLiteralExpression */: + case 155 /* ParenthesizedExpression */: + case 148 /* ObjectLiteralExpression */: + case 156 /* FunctionExpression */: + case 64 /* Identifier */: + case 9 /* RegularExpressionLiteral */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 165 /* TemplateExpression */: + case 79 /* FalseKeyword */: + case 88 /* NullKeyword */: + case 92 /* ThisKeyword */: + case 94 /* TrueKeyword */: + case 90 /* SuperKeyword */: return true; } } return false; } function isAssignmentOperator(token) { - return token >= 51 /* FirstAssignment */ && token <= 62 /* LastAssignment */; + return token >= 52 /* FirstAssignment */ && token <= 63 /* LastAssignment */; } function checkGrammar(sourceText, languageVersion, file) { var grammarDiagnostics = file.grammarDiagnostics; @@ -4916,7 +5726,7 @@ var ts; parent = node; if (!checkModifiers(node)) { var savedInFunctionBlock = inFunctionBlock; - if (node.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(node)) { inFunctionBlock = true; } var savedInAmbientContext = inAmbientContext; @@ -4941,67 +5751,85 @@ var ts; } function checkNode(node, nodeKind) { switch (nodeKind) { - case 153 /* ArrowFunction */: - case 129 /* CallSignature */: - case 134 /* ConstructorType */: - case 130 /* ConstructSignature */: - case 133 /* FunctionType */: - return checkAnyParsedSignature(node); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + case 157 /* ArrowFunction */: + case 132 /* CallSignature */: + case 137 /* ConstructorType */: + case 133 /* ConstructSignature */: + case 136 /* FunctionType */: + return checkAnySignatureDeclaration(node); + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: return checkBreakOrContinueStatement(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return checkCallOrNewExpression(node); - case 191 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 156 /* BinaryExpression */: return checkBinaryExpression(node); - case 182 /* CatchBlock */: return checkCatchBlock(node); - case 188 /* ClassDeclaration */: return checkClassDeclaration(node); - case 126 /* Constructor */: return checkConstructor(node); - case 195 /* ExportAssignment */: return checkExportAssignment(node); - case 170 /* ForInStatement */: return checkForInStatement(node); - case 169 /* ForStatement */: return checkForStatement(node); - case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 152 /* FunctionExpression */: return checkFunctionExpression(node); - case 127 /* GetAccessor */: return checkGetAccessor(node); - case 146 /* IndexedAccess */: return checkIndexedAccess(node); - case 131 /* IndexSignature */: return checkIndexSignature(node); - case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 178 /* LabeledStatement */: return checkLabeledStatement(node); - case 125 /* Method */: return checkMethod(node); - case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 142 /* ObjectLiteral */: return checkObjectLiteral(node); - case 6 /* NumericLiteral */: return checkNumericLiteral(node); - case 123 /* Parameter */: return checkParameter(node); - case 155 /* PostfixOperator */: return checkPostfixOperator(node); - case 154 /* PrefixOperator */: return checkPrefixOperator(node); - case 124 /* Property */: return checkProperty(node); - case 143 /* PropertyAssignment */: return checkPropertyAssignment(node); - case 173 /* ReturnStatement */: return checkReturnStatement(node); - case 128 /* SetAccessor */: return checkSetAccessor(node); - case 197 /* SourceFile */: return checkSourceFile(node); - case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); - case 175 /* SwitchStatement */: return checkSwitchStatement(node); - case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 138 /* TupleType */: return checkTupleType(node); - case 122 /* TypeParameter */: return checkTypeParameter(node); - case 132 /* TypeReference */: return checkTypeReference(node); - case 185 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 163 /* VariableStatement */: return checkVariableStatement(node); - case 174 /* WithStatement */: return checkWithStatement(node); - case 160 /* YieldExpression */: return checkYieldExpression(node); + case 194 /* EnumDeclaration */: return checkEnumDeclaration(node); + case 163 /* BinaryExpression */: return checkBinaryExpression(node); + case 146 /* BindingElement */: return checkBindingElement(node); + case 203 /* CatchClause */: return checkCatchClause(node); + case 191 /* ClassDeclaration */: return checkClassDeclaration(node); + case 122 /* ComputedPropertyName */: return checkComputedPropertyName(node); + case 129 /* Constructor */: return checkConstructor(node); + case 158 /* DeleteExpression */: return checkDeleteExpression(node); + case 150 /* ElementAccessExpression */: return checkElementAccessExpression(node); + case 198 /* ExportAssignment */: return checkExportAssignment(node); + case 199 /* ExternalModuleReference */: return checkExternalModuleReference(node); + case 177 /* ForInStatement */: return checkForInStatement(node); + case 176 /* ForStatement */: return checkForStatement(node); + case 190 /* FunctionDeclaration */: return checkFunctionDeclaration(node); + case 156 /* FunctionExpression */: return checkFunctionExpression(node); + case 130 /* GetAccessor */: return checkGetAccessor(node); + case 202 /* HeritageClause */: return checkHeritageClause(node); + case 134 /* IndexSignature */: return checkIndexSignature(node); + case 192 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); + case 183 /* LabeledStatement */: return checkLabeledStatement(node); + case 204 /* PropertyAssignment */: return checkPropertyAssignment(node); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return checkMethod(node); + case 195 /* ModuleDeclaration */: return checkModuleDeclaration(node); + case 148 /* ObjectLiteralExpression */: return checkObjectLiteralExpression(node); + case 7 /* NumericLiteral */: return checkNumericLiteral(node); + case 124 /* Parameter */: return checkParameter(node); + case 162 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); + case 161 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return checkProperty(node); + case 180 /* ReturnStatement */: return checkReturnStatement(node); + case 131 /* SetAccessor */: return checkSetAccessor(node); + case 207 /* SourceFile */: return checkSourceFile(node); + case 205 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); + case 182 /* SwitchStatement */: return checkSwitchStatement(node); + case 153 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 184 /* ThrowStatement */: return checkThrowStatement(node); + case 141 /* TupleType */: return checkTupleType(node); + case 123 /* TypeParameter */: return checkTypeParameter(node); + case 135 /* TypeReference */: return checkTypeReference(node); + case 189 /* VariableDeclaration */: return checkVariableDeclaration(node); + case 170 /* VariableStatement */: return checkVariableStatement(node); + case 181 /* WithStatement */: return checkWithStatement(node); + case 166 /* YieldExpression */: return checkYieldExpression(node); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var start = ts.skipTrivia(sourceText, node.pos); + function scanToken(pos) { + var start = ts.skipTrivia(sourceText, pos); scanner.setTextPos(start); scanner.scan(); - var end = scanner.getTextPos(); - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, end - start, message, arg0, arg1, arg2)); + return start; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var start = scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + return true; + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); return true; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(node); + var span = ts.getErrorSpanForNode(node); var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos; var length = span.end - start; grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); @@ -5017,27 +5845,27 @@ var ts; } function checkForStatementInAmbientContext(node, kind) { switch (kind) { - case 162 /* Block */: - case 164 /* EmptyStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 184 /* DebuggerStatement */: - case 178 /* LabeledStatement */: - case 165 /* ExpressionStatement */: + case 169 /* Block */: + case 171 /* EmptyStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 188 /* DebuggerStatement */: + case 183 /* LabeledStatement */: + case 172 /* ExpressionStatement */: return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } - function checkAnyParsedSignature(node) { + function checkAnySignatureDeclaration(node) { return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters); } function checkBinaryExpression(node) { @@ -5051,12 +5879,12 @@ var ts; } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: return true; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -5064,11 +5892,11 @@ var ts; function checkLabeledStatement(node) { var current = node.parent; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { break; } - if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) { - return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); + if (current.kind === 183 /* LabeledStatement */ && current.label.text === node.label.text) { + return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceText, node.label)); } current = current.parent; } @@ -5076,21 +5904,21 @@ var ts; function checkBreakOrContinueStatement(node) { var current = node; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 178 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 175 /* SwitchStatement */: - if (node.kind === 172 /* BreakStatement */ && !node.label) { + case 182 /* SwitchStatement */: + if (node.kind === 179 /* BreakStatement */ && !node.label) { return false; } break; @@ -5103,11 +5931,11 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 172 /* 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; + var message = node.kind === 179 /* 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 === 172 /* 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; + var message = node.kind === 179 /* 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); } } @@ -5118,28 +5946,18 @@ var ts; return checkForDisallowedTrailingComma(arguments) || checkForOmittedArgument(arguments); } function checkTypeArguments(typeArguments) { - return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments) || checkForMissingTypeArgument(typeArguments); + return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments); } function checkForOmittedArgument(arguments) { if (arguments) { for (var i = 0, n = arguments.length; i < n; i++) { var arg = arguments[i]; - if (arg.kind === 161 /* OmittedExpression */) { + if (arg.kind === 167 /* OmittedExpression */) { return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkForMissingTypeArgument(typeArguments) { - if (typeArguments) { - for (var i = 0, n = typeArguments.length; i < n; i++) { - var arg = typeArguments[i]; - if (arg.kind === 120 /* Missing */) { - return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Type_expected); - } - } - } - } function checkForAtLeastOneTypeArgument(typeArguments) { if (typeArguments && typeArguments.length === 0) { var start = typeArguments.pos - "<".length; @@ -5154,17 +5972,47 @@ var ts; return grammarErrorAtPos(start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkCatchBlock(node) { + function checkCatchClause(node) { if (node.type) { - var colonStart = ts.skipTrivia(sourceText, node.variable.end); + var colonStart = ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) { - return reportInvalidUseInStrictMode(node.variable); + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } } function checkClassDeclaration(node) { - return checkForDisallowedTrailingComma(node.implementedTypes) || checkForAtLeastOneHeritageClause(node.implementedTypes, "implements"); + return checkClassDeclarationHeritageClauses(node); + } + function checkClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 78 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 101 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + } + } + return false; } function checkForAtLeastOneHeritageClause(types, listType) { if (types && types.length === 0) { @@ -5172,7 +6020,7 @@ var ts; } } function checkConstructor(node) { - return checkAnyParsedSignature(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); + return checkAnySignatureDeclaration(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); } function checkConstructorTypeParameters(node) { if (node.typeParameters) { @@ -5184,6 +6032,11 @@ var ts; return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } } + function checkDeleteExpression(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 64 /* Identifier */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } function checkEnumDeclaration(enumDecl) { var enumIsConst = (enumDecl.flags & 4096 /* Const */) !== 0; var hasError = false; @@ -5191,7 +6044,10 @@ var ts; var inConstantEnumMemberSection = true; for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; - if (inAmbientContext) { + if (node.name.kind === 122 /* ComputedPropertyName */) { + hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { if (node.initializer && !isIntegerLiteral(node.initializer)) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; } @@ -5210,13 +6066,13 @@ var ts; function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 154 /* PrefixOperator */) { + if (expression.kind === 161 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { + if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 6 /* NumericLiteral */) { + if (expression.kind === 7 /* NumericLiteral */) { return isInteger(expression); } return false; @@ -5226,6 +6082,11 @@ var ts; return grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } } + function checkExternalModuleReference(node) { + if (node.expression.kind !== 8 /* StringLiteral */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.String_literal_expected); + } + } function checkForInStatement(node) { return checkVariableDeclarations(node.declarations) || checkForMoreThanOneDeclaration(node.declarations); } @@ -5238,15 +6099,15 @@ var ts; } } function checkFunctionDeclaration(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); } function checkForGenerator(node) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported); + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_currently_supported); } } function checkFunctionExpression(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForGenerator(node); } function checkFunctionName(name) { if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) { @@ -5254,15 +6115,25 @@ var ts; } } function checkGetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } - function checkIndexedAccess(node) { - if (node.index.kind === 120 /* Missing */ && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node) { - var start = ts.skipTrivia(sourceText, node.parent.pos); - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + function checkElementAccessExpression(node) { + if (!node.argumentExpression) { + if (node.parent.kind === 152 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceText, node.expression.end); + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.Expression_expected); + } } } + function checkHeritageClause(node) { + return checkForDisallowedTrailingComma(node.types) || checkForAtLeastOneHeritageClause(node.types, ts.tokenToString(node.token)); + } function checkIndexSignature(node) { return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); } @@ -5281,14 +6152,14 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); } } - else if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + else if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); } else if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); @@ -5296,7 +6167,7 @@ var ts; else if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - else if (parameter.type.kind !== 118 /* StringKeyword */ && parameter.type.kind !== 116 /* NumberKeyword */) { + else if (parameter.type.kind !== 119 /* StringKeyword */ && parameter.type.kind !== 117 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } else if (!node.type) { @@ -5304,13 +6175,52 @@ var ts; } } function checkInterfaceDeclaration(node) { - return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends"); + return checkInterfaceDeclarationHeritageClauses(node); + } + function checkInterfaceDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 78 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 101 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + } + } + return false; } function checkMethod(node) { - return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node); + if (checkAnySignatureDeclaration(node) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node)) { + return true; + } + if (node.parent.kind === 191 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (inAmbientContext) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } + } + else if (node.parent.kind === 192 /* InterfaceDeclaration */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === 139 /* TypeLiteral */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); + } } function checkForBodyInAmbientContext(body, isConstructor) { - if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) { + if (inAmbientContext && body && body.kind === 169 /* Block */) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; return grammarErrorOnFirstToken(body, diagnostic); } @@ -5319,25 +6229,25 @@ var ts; return checkModuleDeclarationName(node) || checkModuleDeclarationStatements(node); } function checkModuleDeclarationName(node) { - if (!inAmbientContext && node.name.kind === 7 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 8 /* StringLiteral */) { return grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } function checkModuleDeclarationStatements(node) { - if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) { + if (node.name.kind === 64 /* Identifier */ && node.body.kind === 196 /* ModuleBlock */) { var statements = node.body.statements; for (var i = 0, n = statements.length; i < n; i++) { var statement = statements[i]; - if (statement.kind === 195 /* ExportAssignment */) { + if (statement.kind === 198 /* ExportAssignment */) { return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) { - return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + else if (ts.isExternalModuleImportDeclaration(statement)) { + return grammarErrorOnNode(ts.getExternalModuleImportDeclarationExpression(statement), ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } } } - function checkObjectLiteral(node) { + function checkObjectLiteralExpression(node) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -5346,26 +6256,22 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; - if (prop.kind === 161 /* OmittedExpression */) { + var name = prop.name; + if (prop.kind === 167 /* OmittedExpression */ || name.kind === 122 /* ComputedPropertyName */) { continue; } - var p = prop; - var name = p.name; var currentKind; - if (p.kind === 143 /* PropertyAssignment */) { + if (prop.kind === 204 /* PropertyAssignment */ || prop.kind === 205 /* ShorthandPropertyAssignment */ || prop.kind === 128 /* MethodDeclaration */) { currentKind = Property; } - else if (p.kind === 144 /* ShorthandPropertyAssignment */) { - currentKind = Property; - } - else if (p.kind === 127 /* GetAccessor */) { + else if (prop.kind === 130 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 128 /* SetAccessor */) { + else if (prop.kind === 131 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + p.kind); + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } if (!ts.hasProperty(seen, name.text)) { seen[name.text] = currentKind; @@ -5403,22 +6309,24 @@ var ts; } function checkModifiers(node) { switch (node.kind) { - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 124 /* Property */: - case 125 /* Method */: - case 131 /* IndexSignature */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 195 /* ExportAssignment */: - case 163 /* VariableStatement */: - case 186 /* FunctionDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 194 /* ImportDeclaration */: - case 123 /* Parameter */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 134 /* IndexSignature */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 195 /* ModuleDeclaration */: + case 194 /* EnumDeclaration */: + case 198 /* ExportAssignment */: + case 170 /* VariableStatement */: + case 190 /* FunctionDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 197 /* ImportDeclaration */: + case 124 /* Parameter */: break; default: return false; @@ -5431,14 +6339,14 @@ var ts; for (var i = 0, n = node.modifiers.length; i < n; i++) { var modifier = node.modifiers[i]; switch (modifier.kind) { - case 106 /* PublicKeyword */: - case 105 /* ProtectedKeyword */: - case 104 /* PrivateKeyword */: + case 107 /* PublicKeyword */: + case 106 /* ProtectedKeyword */: + case 105 /* PrivateKeyword */: var text; - if (modifier.kind === 106 /* PublicKeyword */) { + if (modifier.kind === 107 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 105 /* ProtectedKeyword */) { + else if (modifier.kind === 106 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -5452,50 +6360,50 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 196 /* ModuleBlock */ || node.parent.kind === 207 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= modifierToFlag(modifier.kind); break; - case 107 /* StaticKeyword */: + case 108 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 196 /* ModuleBlock */ || node.parent.kind === 207 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; lastStatic = modifier; break; - case 76 /* ExportKeyword */: + case 77 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 112 /* DeclareKeyword */: + case 113 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 123 /* Parameter */) { + else if (node.kind === 124 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) { + else if (inAmbientContext && node.parent.kind === 196 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -5503,7 +6411,7 @@ var ts; break; } } - if (node.kind === 126 /* Constructor */) { + if (node.kind === 129 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -5514,10 +6422,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 197 /* ImportDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 192 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } @@ -5544,20 +6452,20 @@ var ts; var parameterCount = parameters.length; for (var i = 0; i < parameterCount; i++) { var parameter = parameters[i]; - if (parameter.flags & 8 /* Rest */) { + if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); } if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.flags & 4 /* QuestionMark */ || parameter.initializer) { + else if (parameter.questionToken || parameter.initializer) { seenOptionalParameter = true; - if (parameter.flags & 4 /* QuestionMark */ && parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -5568,23 +6476,49 @@ var ts; } } } - function checkPostfixOperator(node) { + function checkPostfixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } } - function checkPrefixOperator(node) { + function checkPrefixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */) { - if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { + if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } - else if (node.operator === 72 /* DeleteKeyword */ && node.operand.kind === 63 /* Identifier */) { - return grammarErrorOnNode(node.operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } } } function checkProperty(node) { - return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node); + if (node.parent.kind === 191 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === 192 /* InterfaceDeclaration */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === 139 /* TypeLiteral */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { + return true; + } + } + return checkForInitializerInAmbientContext(node); + } + function checkComputedPropertyName(node) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_not_currently_supported); + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (node.expression.kind === 163 /* BinaryExpression */ && node.expression.operator === 23 /* CommaToken */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkForDisallowedComputedProperty(node, message) { + if (node.kind === 122 /* ComputedPropertyName */) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node) { if (inAmbientContext && node.initializer) { @@ -5592,12 +6526,11 @@ var ts; } } function checkPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } - function checkForInvalidQuestionMark(node, message) { - if (node.flags & 4 /* QuestionMark */) { - var pos = ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(pos, "?".length, message); + function checkForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); } } function checkReturnStatement(node) { @@ -5606,7 +6539,7 @@ var ts; } } function checkSetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } function checkAccessor(accessor) { var kind = accessor.kind; @@ -5622,10 +6555,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 127 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 130 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 128 /* SetAccessor */) { + else if (kind === 131 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -5634,14 +6567,14 @@ var ts; } else { var parameter = accessor.parameters[0]; - if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); } else if (parameter.initializer) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); @@ -5655,7 +6588,7 @@ var ts; function checkTopLevelElementsForRequiredDeclareModifier(file) { for (var i = 0, n = file.statements.length; i < n; i++) { var decl = file.statements[i]; - if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 170 /* VariableStatement */) { if (checkTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -5663,19 +6596,19 @@ var ts; } } function checkTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { + if (node.kind === 192 /* InterfaceDeclaration */ || node.kind === 197 /* ImportDeclaration */ || node.kind === 198 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); } function checkShorthandPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } function checkSwitchStatement(node) { var firstDefaultClause; for (var i = 0, n = node.clauses.length; i < n; i++) { var clause = node.clauses[i]; - if (clause.kind === 177 /* DefaultClause */) { + if (clause.kind === 201 /* DefaultClause */) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -5692,6 +6625,11 @@ var ts; return grammarErrorOnFirstToken(node.template, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } } + function checkThrowStatement(node) { + if (node.expression === undefined) { + return grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } function checkTupleType(node) { return checkForDisallowedTrailingComma(node.elementTypes) || checkForAtLeastOneType(node); } @@ -5708,13 +6646,29 @@ var ts; function checkTypeReference(node) { return checkTypeArguments(node.typeArguments); } - function checkVariableDeclaration(node) { - if (inAmbientContext && node.initializer) { - var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + function checkBindingElement(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } - if (!inAmbientContext && !node.initializer && isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + function checkVariableDeclaration(node) { + if (inAmbientContext) { + if (ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); + } + if (node.initializer) { + return grammarErrorAtPos(node.initializer.pos - 1, 1, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else { + if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } } if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { return reportInvalidUseInStrictMode(node.name); @@ -5730,10 +6684,10 @@ var ts; } var decl = declarations[0]; if (languageVersion < 2 /* ES6 */) { - if (isLet(decl)) { + if (ts.isLet(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } - else if (isConst(decl)) { + else if (ts.isConst(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } @@ -5744,24 +6698,24 @@ var ts; } function checkForDisallowedLetOrConstStatement(node) { if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node)) { + if (ts.isLet(node)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (isConst(node)) { + else if (ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 181 /* WithStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: return false; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -5787,7 +6741,7 @@ var ts; var commonSourceDirectory; ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(), true); + processRootFile(host.getDefaultLibFilename(options), true); } verifyCompilerOptions(); errors.sort(ts.compareDiagnostics); @@ -5825,7 +6779,7 @@ var ts; } var diagnostic; if (hasExtension(filename)) { - if (!ts.fileExtensionIs(filename, ".ts")) { + if (!options.allowNonTsExtensions && !ts.fileExtensionIs(filename, ".ts")) { diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts; } else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { @@ -5903,8 +6857,8 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchPath = basePath; @@ -5921,10 +6875,10 @@ var ts; } } } - else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 195 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); @@ -5951,9 +6905,9 @@ var ts; } return; } - var firstExternalModule = ts.forEach(files, function (f) { return isExternalModule(f) ? f : undefined; }); + var firstExternalModule = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModule && options.module === 0 /* None */) { - var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator); + var externalModuleErrorSpan = ts.getErrorSpanForNode(firstExternalModule.externalModuleIndicator); var errorStart = ts.skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); var errorLength = externalModuleErrorSpan.end - errorStart; errors.push(ts.createFileDiagnostic(firstExternalModule, errorStart, errorLength, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); @@ -5996,16 +6950,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + else if (node.kind === 197 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 193 /* ModuleBlock */) { + else if (node.kind === 196 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -6021,7 +6975,7 @@ var ts; }); return state; } - else if (node.kind === 192 /* ModuleDeclaration */) { + else if (node.kind === 195 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -6029,6 +6983,10 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + function hasComputedNameButNotSymbol(declaration) { + return declaration.name && declaration.name.kind === 122 /* ComputedPropertyName */; + } + ts.hasComputedNameButNotSymbol = hasComputedNameButNotSymbol; function bindSourceFile(file) { var parent; var container; @@ -6061,21 +7019,22 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 195 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } + ts.Debug.assert(!hasComputedNameButNotSymbol(node)); return node.name.text; } switch (node.kind) { - case 134 /* ConstructorType */: - case 126 /* Constructor */: + case 137 /* ConstructorType */: + case 129 /* Constructor */: return "__constructor"; - case 133 /* FunctionType */: - case 129 /* CallSignature */: + case 136 /* FunctionType */: + case 132 /* CallSignature */: return "__call"; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: return "__new"; - case 131 /* IndexSignature */: + case 134 /* IndexSignature */: return "__index"; } } @@ -6083,6 +7042,9 @@ var ts; return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } function declareSymbol(symbols, parent, node, includes, excludes) { + if (hasComputedNameButNotSymbol(node)) { + return undefined; + } var name = getDeclarationName(node); if (name !== undefined) { var symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); @@ -6103,8 +7065,8 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) { - var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); + if (node.kind === 191 /* ClassDeclaration */ && symbol.exports) { + var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { node.name.parent = node; @@ -6127,15 +7089,15 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var exportKind = 0; if (symbolKind & 107455 /* Value */) { - exportKind |= 4194304 /* ExportValue */; + exportKind |= 1048576 /* ExportValue */; } - if (symbolKind & 3152352 /* Type */) { - exportKind |= 8388608 /* ExportType */; + if (symbolKind & 793056 /* Type */) { + exportKind |= 2097152 /* ExportType */; } if (symbolKind & 1536 /* Namespace */) { - exportKind |= 16777216 /* ExportNamespace */; + exportKind |= 4194304 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 197 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6150,14 +7112,14 @@ var ts; } } function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 1041936 /* HasLocals */) { + if (symbolKind & 255504 /* HasLocals */) { node.locals = {}; } var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolKind & 1048560 /* IsContainer */) { + if (symbolKind & 262128 /* IsContainer */) { container = node; if (lastContainer !== container && !container.nextContainer) { if (lastContainer) { @@ -6176,39 +7138,40 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 136 /* TypeLiteral */: - case 142 /* ObjectLiteral */: - case 189 /* InterfaceDeclaration */: + case 139 /* TypeLiteral */: + case 148 /* ObjectLiteralExpression */: + case 192 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -6223,7 +7186,7 @@ var ts; }); } function bindModuleDeclaration(node) { - if (node.name.kind === 7 /* StringLiteral */) { + if (node.name.kind === 8 /* StringLiteral */) { bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); } else { @@ -6243,14 +7206,13 @@ var ts; } } function bindFunctionOrConstructorType(node) { - var symbolKind = node.kind === 133 /* FunctionType */ ? 131072 /* CallSignature */ : 262144 /* ConstructSignature */; - var symbol = createSymbol(symbolKind, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, false); + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072 /* Signature */); + bindChildren(node, 131072 /* Signature */, false); var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 133 /* FunctionType */ ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 136 /* FunctionType */ ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -6258,7 +7220,7 @@ var ts; bindChildren(node, symbolKind, isBlockScopeContainer); } function bindCatchVariableDeclaration(node) { - var symbol = createSymbol(1 /* FunctionScopedVariable */, node.variable.text || "__missing"); + var symbol = createSymbol(1 /* FunctionScopedVariable */, node.name.text || "__missing"); addDeclarationToSymbol(symbol, node, 1 /* FunctionScopedVariable */); var saveParent = parent; var savedBlockScopeContainer = blockScopeContainer; @@ -6269,10 +7231,10 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; @@ -6285,107 +7247,119 @@ var ts; } bindChildren(node, 2 /* BlockScopedVariable */, false); } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } function bind(node) { node.parent = parent; switch (node.kind) { - case 122 /* TypeParameter */: - bindDeclaration(node, 1048576 /* TypeParameter */, 2103776 /* TypeParameterExcludes */, false); + case 123 /* TypeParameter */: + bindDeclaration(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */, false); break; - case 123 /* Parameter */: - bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); + case 124 /* Parameter */: + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node), false); + } + else { + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); + } break; - case 185 /* VariableDeclaration */: - if (node.flags & 6144 /* BlockScoped */) { + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + if (ts.isBindingPattern(node.name)) { + bindChildren(node, 0, false); + } + else if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } else { bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + bindDeclaration(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0), 107455 /* PropertyExcludes */, false); + break; + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 196 /* EnumMember */: + case 206 /* EnumMember */: bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 129 /* CallSignature */: - bindDeclaration(node, 131072 /* CallSignature */, 0, false); + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + bindDeclaration(node, 131072 /* Signature */, 0, false); break; - case 130 /* ConstructSignature */: - bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + bindDeclaration(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; - case 125 /* Method */: - bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); - break; - case 131 /* IndexSignature */: - bindDeclaration(node, 524288 /* IndexSignature */, 0, false); - break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 126 /* Constructor */: + case 129 /* Constructor */: bindConstructorDeclaration(node); break; - case 127 /* GetAccessor */: + case 130 /* GetAccessor */: bindDeclaration(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 128 /* SetAccessor */: + case 131 /* SetAccessor */: bindDeclaration(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 133 /* FunctionType */: - case 134 /* ConstructorType */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: bindFunctionOrConstructorType(node); break; - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 182 /* CatchBlock */: + case 203 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 188 /* ClassDeclaration */: - bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); + case 191 /* ClassDeclaration */: + bindDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */, false); break; - case 189 /* InterfaceDeclaration */: - bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); + case 192 /* InterfaceDeclaration */: + bindDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */, false); break; - case 190 /* TypeAliasDeclaration */: - bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); + case 193 /* TypeAliasDeclaration */: + bindDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */, false); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: if (ts.isConst(node)) { - bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); + bindDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */, false); } else { - bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); + bindDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */, false); } break; - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 194 /* ImportDeclaration */: - bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); + case 197 /* ImportDeclaration */: + bindDeclaration(node, 8388608 /* Import */, 8388608 /* ImportExcludes */, false); break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 175 /* SwitchStatement */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 182 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6571,7 +7545,7 @@ var ts; } function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && member.body) { + if (member.kind === 129 /* Constructor */ && member.body) { return member; } }); @@ -6580,19 +7554,33 @@ var ts; var firstAccessor; var getAccessor; var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 127 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 128 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } + if (accessor.name.kind === 122 /* ComputedPropertyName */) { + firstAccessor = accessor; + if (accessor.kind === 130 /* GetAccessor */) { + getAccessor = accessor; } - }); + else if (accessor.kind === 131 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(node.members, function (member) { + if ((member.kind === 130 /* GetAccessor */ || member.kind === 131 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 130 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 131 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + } return { firstAccessor: firstAccessor, getAccessor: getAccessor, @@ -6694,14 +7682,14 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } - function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) { + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); if (type) { emitType(type); } else { - resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -6739,37 +7727,37 @@ var ts; emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); } } - function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) { + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; emitType(type); } function emitType(type) { switch (type.kind) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 7 /* StringLiteral */: + case 110 /* AnyKeyword */: + case 119 /* StringKeyword */: + case 117 /* NumberKeyword */: + case 111 /* BooleanKeyword */: + case 98 /* VoidKeyword */: + case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return emitTypeReference(type); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return emitTypeQuery(type); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return emitArrayType(type); - case 138 /* TupleType */: + case 141 /* TupleType */: return emitTupleType(type); - case 139 /* UnionType */: + case 142 /* UnionType */: return emitUnionType(type); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return emitParenType(type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: return emitTypeLiteral(type); - case 63 /* Identifier */: + case 64 /* Identifier */: return emitEntityName(type); case 121 /* QualifiedName */: return emitEntityName(type); @@ -6777,11 +7765,11 @@ var ts; ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 197 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { - if (entityName.kind === 63 /* Identifier */) { + if (entityName.kind === 64 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { @@ -6848,7 +7836,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 189 /* InterfaceDeclaration */) { + if (node.kind !== 192 /* InterfaceDeclaration */) { write("declare "); } } @@ -6884,13 +7872,13 @@ var ts; write("import "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - if (node.entityName) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError); + if (ts.isInternalModuleImportDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); write(";"); } else { write("require("); - writeTextOfNode(currentSourceFile, node.externalModuleName); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportDeclarationExpression(node)); write(");"); } writer.writeLine(); @@ -6908,7 +7896,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 193 /* ModuleBlock */) { + while (node.body.kind !== 196 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -6932,7 +7920,7 @@ var ts; write("type "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); } @@ -6973,49 +7961,53 @@ var ts; write(","); writeLine(); } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 128 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { increaseIndent(); emitJsDocComments(node); decreaseIndent(); writeTextOfNode(currentSourceFile, node.name); - if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 136 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 125 /* Method */ || node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.kind === 129 /* CallSignature */ || node.parent.kind === 130 /* ConstructSignature */); + if (node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 139 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 128 /* MethodDeclaration */ || node.parent.kind === 127 /* MethodSignature */ || node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || node.parent.kind === 132 /* CallSignature */ || node.parent.kind === 133 /* ConstructSignature */); emitType(node.constraint); } else { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 191 /* 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 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7040,10 +8032,10 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 188 /* ClassDeclaration */) { + if (node.parent.parent.kind === 191 /* ClassDeclaration */) { 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; } else { @@ -7052,7 +8044,7 @@ var ts; return { diagnosticMessage: diagnosticMessage, errorNode: node, - typeName: node.parent.name + typeName: node.parent.parent.name }; } } @@ -7075,10 +8067,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } - emitHeritageClause(node.implementedTypes, true); + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); write(" {"); writeLine(); increaseIndent(); @@ -7099,7 +8092,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); write(" {"); writeLine(); increaseIndent(); @@ -7118,28 +8111,28 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 189 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { writeTextOfNode(currentSourceFile, node.name); - if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if ((node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) { + if ((node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) && node.parent.kind === 139 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 185 /* VariableDeclaration */) { + if (node.kind === 189 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 124 /* Property */) { + else if (node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -7189,25 +8182,25 @@ var ts; var accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 127 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 130 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; } } - writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); } write(";"); writeLine(); } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 127 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type; + return accessor.kind === 130 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type; } } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 128 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 131 /* SetAccessor */) { if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -7236,24 +8229,24 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 190 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 190 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 125 /* Method */) { + else if (node.kind === 128 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 190 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 126 /* Constructor */) { + else if (node.kind === 129 /* Constructor */) { write("constructor"); } else { writeTextOfNode(currentSourceFile, node.name); - if (node.flags & 4 /* QuestionMark */) { + if (ts.hasQuestionToken(node)) { write("?"); } } @@ -7265,11 +8258,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 130 /* ConstructSignature */ || node.kind === 134 /* ConstructorType */) { + if (node.kind === 133 /* ConstructSignature */ || node.kind === 137 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 131 /* IndexSignature */) { + if (node.kind === 134 /* IndexSignature */) { write("["); } else { @@ -7278,20 +8271,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 131 /* IndexSignature */) { + if (node.kind === 134 /* IndexSignature */) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 133 /* FunctionType */ || node.kind === 134 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 136 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 136 /* FunctionType */ || node.kind === 137 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 139 /* TypeLiteral */) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 129 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -7302,27 +8295,28 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 131 /* IndexSignature */: + case 134 /* IndexSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: @@ -7337,44 +8331,50 @@ var ts; function emitParameterDeclaration(node) { increaseIndent(); emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { + if (node.dotDotDotToken) { write("..."); } - writeTextOfNode(currentSourceFile, node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + if (ts.isBindingPattern(node.name)) { + write("_" + ts.indexOf(node.parent.parameters, node)); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (node.initializer || ts.hasQuestionToken(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.parent.kind === 136 /* TypeLiteral */) { + if (node.parent.kind === 136 /* FunctionType */ || node.parent.kind === 137 /* ConstructorType */ || node.parent.parent.kind === 139 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 126 /* Constructor */: + case 129 /* Constructor */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 191 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7389,38 +8389,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: + case 129 /* Constructor */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: return emitFunctionDeclaration(node); - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: + case 133 /* ConstructSignature */: + case 132 /* CallSignature */: + case 134 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return emitAccessorDeclaration(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return emitVariableStatement(node); - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return emitPropertyDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return emitClassDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 193 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 196 /* EnumMember */: + case 206 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return emitImportDeclaration(node); - case 195 /* ExportAssignment */: + case 198 /* ExportAssignment */: return emitExportAssignment(node); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return emitSourceFile(node); } } @@ -7492,6 +8494,9 @@ var ts; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; var extendsEmitted = false; + var tempCount = 0; + var tempVariables; + var tempParameters; var writeEmittedFiles = writeJavaScriptFile; var emitLeadingComments = compilerOptions.removeComments ? function (node) { } : emitLeadingDeclarationComments; @@ -7647,7 +8652,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) { + else if (node.kind === 190 /* FunctionDeclaration */ || node.kind === 156 /* FunctionExpression */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 130 /* GetAccessor */ || node.kind === 131 /* SetAccessor */ || node.kind === 195 /* ModuleDeclaration */ || node.kind === 191 /* ClassDeclaration */ || node.kind === 194 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -7729,7 +8734,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 197 /* SourceFile */) { + if (node.kind != 207 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -7752,6 +8757,38 @@ var ts; function writeJavaScriptFile(emitOutput, writeByteOrderMark) { writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } + function createTempVariable(location, forLoopVariable) { + var name = forLoopVariable ? "_i" : undefined; + while (true) { + if (name && resolver.isUnknownIdentifier(location, name)) { + break; + } + name = "_" + (tempCount < 25 ? String.fromCharCode(tempCount + (tempCount < 8 ? 0 : 1) + 97 /* a */) : tempCount - 25); + tempCount++; + } + var result = ts.createNode(64 /* Identifier */); + result.text = name; + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } function emitTokenText(tokenKind, startPos, emitFn) { var tokenString = ts.tokenToString(tokenKind); if (emitFn) { @@ -7768,15 +8805,12 @@ var ts; emit(node); } } - function emitTrailingCommaIfPresent(nodeList, isMultiline) { + function emitTrailingCommaIfPresent(nodeList) { if (nodeList.hasTrailingComma) { write(","); - if (isMultiline) { - writeLine(); - } } } - function emitCommaList(nodes, includeTrailingComma, count) { + function emitCommaList(nodes, count) { if (!(count >= 0)) { count = nodes.length; } @@ -7787,12 +8821,9 @@ var ts; } emit(nodes[i]); } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, false); - } } } - function emitMultiLineList(nodes, includeTrailingComma) { + function emitMultiLineList(nodes) { if (nodes) { for (var i = 0; i < nodes.length; i++) { if (i) { @@ -7801,9 +8832,6 @@ var ts; writeLine(); emit(nodes[i]); } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, true); - } } } function emitLines(nodes) { @@ -7815,20 +8843,26 @@ var ts; emit(nodes[i]); } } + function isBinaryOrOctalIntegerLiteral(text) { + if (text.length <= 0) { + return false; + } + if (text.charCodeAt(1) === 66 /* B */ || text.charCodeAt(1) === 98 /* b */ || text.charCodeAt(1) === 79 /* O */ || text.charCodeAt(1) === 111 /* o */) { + return true; + } + return false; + } function emitLiteral(node) { - var text = getLiteralText(); - if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + var text = compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; + if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } + else if (compilerOptions.target < 2 /* ES6 */ && node.kind === 7 /* NumericLiteral */ && isBinaryOrOctalIntegerLiteral(text)) { + write(node.text); + } else { write(text); } - function getLiteralText() { - if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) { - return getTemplateLiteralAsStringLiteral(node); - } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } } function getTemplateLiteralAsStringLiteral(node) { return '"' + ts.escapeString(node.text) + '"'; @@ -7838,14 +8872,14 @@ var ts; ts.forEachChild(node, emit); return; } - ts.Debug.assert(node.parent.kind !== 149 /* TaggedTemplateExpression */); + ts.Debug.assert(node.parent.kind !== 153 /* TaggedTemplateExpression */); var emitOuterParens = ts.isExpression(node.parent) && templateNeedsParens(node, node.parent); if (emitOuterParens) { write("("); } emitLiteral(node.head); ts.forEach(node.templateSpans, function (templateSpan) { - var needsParens = templateSpan.expression.kind !== 151 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + var needsParens = templateSpan.expression.kind !== 155 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; write(" + "); if (needsParens) { write("("); @@ -7864,12 +8898,12 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.func === template; - case 151 /* ParenExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return parent.expression === template; + case 155 /* ParenthesizedExpression */: return false; - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: ts.Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -7878,18 +8912,18 @@ var ts; function comparePrecedenceToBinaryPlus(expression) { ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); switch (expression.kind) { - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: switch (expression.operator) { - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: return 1 /* GreaterThan */; - case 32 /* PlusToken */: + case 33 /* PlusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -7901,12 +8935,15 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - if (node.kind === 7 /* StringLiteral */) { + if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } + else if (node.kind === 122 /* ComputedPropertyName */) { + emit(node.expression); + } else { write("\""); - if (node.kind === 6 /* NumericLiteral */) { + if (node.kind === 7 /* NumericLiteral */) { write(node.text); } else { @@ -7918,31 +8955,34 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 190 /* FunctionDeclaration */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: return parent.name === node; - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 195 /* ExportAssignment */: + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 198 /* ExportAssignment */: return false; - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return node.parent.label === node; - case 182 /* CatchBlock */: - return node.parent.variable === node; + case 203 /* CatchClause */: + return node.parent.name === node; } } function emitExpressionIdentifier(node) { @@ -7954,7 +8994,10 @@ var ts; writeTextOfNode(currentSourceFile, node); } function emitIdentifier(node) { - if (!isNotExpressionIdentifier(node)) { + if (!node.parent) { + write(node.text); + } + else if (!isNotExpressionIdentifier(node)) { emitExpressionIdentifier(node); } else { @@ -7981,18 +9024,32 @@ var ts; write("super"); } } + function emitObjectBindingPattern(node) { + write("{ "); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); + write("]"); + } function emitArrayLiteral(node) { if (node.flags & 256 /* MultiLine */) { write("["); increaseIndent(); - emitMultiLineList(node.elements, true); + emitMultiLineList(node.elements); + emitTrailingCommaIfPresent(node.elements); decreaseIndent(); writeLine(); write("]"); } else { write("["); - emitCommaList(node.elements, true); + emitCommaList(node.elements); + emitTrailingCommaIfPresent(node.elements); write("]"); } } @@ -8003,17 +9060,40 @@ var ts; else if (node.flags & 256 /* MultiLine */) { write("{"); increaseIndent(); - emitMultiLineList(node.properties, compilerOptions.target >= 1 /* ES5 */); + emitMultiLineList(node.properties); + if (compilerOptions.target >= 1 /* ES5 */) { + emitTrailingCommaIfPresent(node.properties); + } decreaseIndent(); writeLine(); write("}"); } else { write("{ "); - emitCommaList(node.properties, compilerOptions.target >= 1 /* ES5 */); + emitCommaList(node.properties); + if (compilerOptions.target >= 1 /* ES5 */) { + emitTrailingCommaIfPresent(node.properties); + } write(" }"); } } + function emitComputedPropertyName(node) { + write("["); + emit(node.expression); + write("]"); + } + function emitMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + if (compilerOptions.target < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + emitTrailingComments(node); + } function emitPropertyAssignment(node) { emitLeadingComments(node); emit(node.name); @@ -8021,33 +9101,19 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitShortHandPropertyAssignment(node) { - function emitAsNormalPropertyAssignment() { - emitLeadingComments(node); - emit(node.name); + function emitShorthandPropertyAssignment(node) { + emitLeadingComments(node); + emit(node.name); + if (compilerOptions.target < 2 /* ES6 */ || resolver.getExpressionNamePrefix(node.name)) { write(": "); emitExpressionIdentifier(node.name); - emitTrailingComments(node); - } - if (compilerOptions.target < 2 /* ES6 */) { - emitAsNormalPropertyAssignment(); - } - else if (compilerOptions.target >= 2 /* ES6 */) { - var prefix = resolver.getExpressionNamePrefix(node.name); - if (prefix) { - emitAsNormalPropertyAssignment(); - } - else { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } } + emitTrailingComments(node); } function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === 145 /* PropertyAccess */ ? ts.declarationNameToString(node.right) : ts.getTextOfNode(node.index); + var propertyName = node.kind === 149 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } @@ -8057,6 +9123,11 @@ var ts; if (tryEmitConstantValue(node)) { return; } + emit(node.expression); + write("."); + emit(node.name); + } + function emitQualifiedName(node) { emit(node.left); write("."); emit(node.right); @@ -8065,42 +9136,42 @@ var ts; if (tryEmitConstantValue(node)) { return; } - emit(node.object); + emit(node.expression); write("["); - emit(node.index); + emit(node.argumentExpression); write("]"); } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 90 /* SuperKeyword */) { write("_super"); superCall = true; } else { - emit(node.func); - superCall = node.func.kind === 145 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; + emit(node.expression); + superCall = node.expression.kind === 149 /* PropertyAccessExpression */ && node.expression.expression.kind === 90 /* SuperKeyword */; } if (superCall) { write(".call("); - emitThis(node.func); + emitThis(node.expression); if (node.arguments.length) { write(", "); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); } write(")"); } else { write("("); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); write(")"); } } function emitNewExpression(node) { write("new "); - emit(node.func); + emit(node.expression); if (node.arguments) { write("("); - emitCommaList(node.arguments, false); + emitCommaList(node.arguments); write(")"); } } @@ -8111,12 +9182,12 @@ var ts; emit(node.template); } function emitParenExpression(node) { - if (node.expression.kind === 150 /* TypeAssertion */) { - var operand = node.expression.operand; - while (operand.kind == 150 /* TypeAssertion */) { - operand = operand.operand; + if (node.expression.kind === 154 /* TypeAssertionExpression */) { + var operand = node.expression.expression; + while (operand.kind == 154 /* TypeAssertionExpression */) { + operand = operand.expression; } - if (operand.kind !== 154 /* PrefixOperator */ && operand.kind !== 155 /* PostfixOperator */ && operand.kind !== 148 /* NewExpression */ && !(operand.kind === 147 /* CallExpression */ && node.parent.kind === 148 /* NewExpression */) && !(operand.kind === 152 /* FunctionExpression */ && node.parent.kind === 147 /* CallExpression */)) { + if (operand.kind !== 161 /* PrefixUnaryExpression */ && operand.kind !== 160 /* VoidExpression */ && operand.kind !== 159 /* TypeOfExpression */ && operand.kind !== 158 /* DeleteExpression */ && operand.kind !== 162 /* PostfixUnaryExpression */ && operand.kind !== 152 /* NewExpression */ && !(operand.kind === 151 /* CallExpression */ && node.parent.kind === 152 /* NewExpression */) && !(operand.kind === 156 /* FunctionExpression */ && node.parent.kind === 151 /* CallExpression */)) { emit(operand); return; } @@ -8125,34 +9196,50 @@ var ts; emit(node.expression); write(")"); } - function emitUnaryExpression(node) { - if (node.kind === 154 /* PrefixOperator */) { - write(ts.tokenToString(node.operator)); - } - if (node.operator >= 63 /* Identifier */) { - write(" "); - } - else if (node.kind === 154 /* PrefixOperator */ && node.operand.kind === 154 /* PrefixOperator */) { + function emitDeleteExpression(node) { + write(ts.tokenToString(73 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(98 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(96 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function emitPrefixUnaryExpression(node) { + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 161 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { + if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 33 /* MinusToken */ && (operand.operator === 33 /* MinusToken */ || operand.operator === 38 /* MinusMinusToken */)) { + else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { write(" "); } } emit(node.operand); - if (node.kind === 155 /* PostfixOperator */) { - write(ts.tokenToString(node.operator)); - } + } + function emitPostfixUnaryExpression(node) { + emit(node.operand); + write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { - emit(node.left); - if (node.operator !== 22 /* CommaToken */) + if (node.operator === 52 /* EqualsToken */ && (node.left.kind === 148 /* ObjectLiteralExpression */ || node.left.kind === 147 /* ArrayLiteralExpression */)) { + emitDestructuring(node); + } + else { + emit(node.left); + if (node.operator !== 23 /* CommaToken */) + write(" "); + write(ts.tokenToString(node.operator)); write(" "); - write(ts.tokenToString(node.operator)); - write(" "); - emit(node.right); + emit(node.right); + } } function emitConditionalExpression(node) { emit(node.condition); @@ -8162,21 +9249,24 @@ var ts; emit(node.whenFalse); } function emitBlock(node) { - emitToken(13 /* OpenBraceToken */, node.pos); + emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 193 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */); + if (node.kind === 196 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 195 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); + if (node.kind === 196 /* ModuleBlock */) { + emitTempDeclarations(true); + } decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.statements.end); + emitToken(15 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 162 /* Block */) { + if (node.kind === 169 /* Block */) { write(" "); emit(node); } @@ -8188,7 +9278,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 153 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 157 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -8200,16 +9290,16 @@ var ts; } function emitIfStatement(node) { emitLeadingComments(node); - var endPos = emitToken(82 /* IfKeyword */, node.pos); + var endPos = emitToken(83 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); + emitToken(17 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(74 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 166 /* IfStatement */) { + emitToken(75 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 173 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -8222,7 +9312,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 162 /* Block */) { + if (node.statement.kind === 169 /* Block */) { write(" "); } else { @@ -8239,21 +9329,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); + var endPos = emitToken(81 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations[0] && ts.isLet(node.declarations[0])) { - emitToken(102 /* LetKeyword */, endPos); + emitToken(103 /* LetKeyword */, endPos); } else if (node.declarations[0] && ts.isConst(node.declarations[0])) { - emitToken(68 /* ConstKeyword */, endPos); + emitToken(69 /* ConstKeyword */, endPos); } else { - emitToken(96 /* VarKeyword */, endPos); + emitToken(97 /* VarKeyword */, endPos); } write(" "); - emitCommaList(node.declarations, false); + emitCommaList(node.declarations); } if (node.initializer) { emit(node.initializer); @@ -8266,17 +9356,17 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); + var endPos = emitToken(81 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); + endPos = emitToken(16 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; if (ts.isLet(decl)) { - emitToken(102 /* LetKeyword */, endPos); + emitToken(103 /* LetKeyword */, endPos); } else { - emitToken(96 /* VarKeyword */, endPos); + emitToken(97 /* VarKeyword */, endPos); } write(" "); emit(decl); @@ -8287,17 +9377,17 @@ var ts; } write(" in "); emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); + emitToken(17 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 179 /* BreakStatement */ ? 65 /* BreakKeyword */ : 70 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { emitLeadingComments(node); - emitToken(88 /* ReturnKeyword */, node.pos); + emitToken(89 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); emitTrailingComments(node); @@ -8309,24 +9399,24 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(90 /* SwitchKeyword */, node.pos); + var endPos = emitToken(91 /* SwitchKeyword */, node.pos); write(" "); - emitToken(15 /* OpenParenToken */, endPos); + emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(16 /* CloseParenToken */, node.expression.end); + endPos = emitToken(17 /* CloseParenToken */, node.expression.end); write(" "); - emitToken(13 /* OpenBraceToken */, endPos); + emitToken(14 /* OpenBraceToken */, endPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.clauses.end); + emitToken(15 /* CloseBraceToken */, node.clauses.end); } function isOnSameLine(node1, node2) { return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 176 /* CaseClause */) { + if (node.kind === 200 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -8352,25 +9442,25 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchBlock); + emit(node.catchClause); if (node.finallyBlock) { writeLine(); write("finally "); emit(node.finallyBlock); } } - function emitCatchBlock(node) { + function emitCatchClause(node) { writeLine(); - var endPos = emitToken(66 /* CatchKeyword */, node.pos); + var endPos = emitToken(67 /* CatchKeyword */, node.pos); write(" "); - emitToken(15 /* OpenParenToken */, endPos); - emit(node.variable); - emitToken(16 /* CloseParenToken */, node.variable.end); + emitToken(16 /* OpenParenToken */, endPos); + emit(node.name); + emitToken(17 /* CloseParenToken */, node.name.end); write(" "); - emitBlock(node); + emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(70 /* DebuggerKeyword */, node.pos); + emitToken(71 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -8381,7 +9471,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 192 /* ModuleDeclaration */); + } while (node && node.kind !== 195 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -8394,10 +9484,183 @@ var ts; emitNode(node.name); emitEnd(node.name); } + function emitDestructuring(root, value) { + var emitCount = 0; + var isDeclaration = (root.kind === 189 /* VariableDeclaration */ && !(root.flags & 1 /* Export */)) || root.kind === 124 /* Parameter */; + if (root.kind === 163 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + emitBindingElement(root, value); + } + function emitAssignment(name, value) { + if (emitCount++) { + write(", "); + } + if (name.parent && (name.parent.kind === 189 /* VariableDeclaration */ || name.parent.kind === 146 /* BindingElement */)) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + } + function ensureIdentifier(expr) { + if (expr.kind !== 64 /* Identifier */) { + var identifier = createTempVariable(root); + if (!isDeclaration) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + expr = identifier; + } + return expr; + } + function createVoidZero() { + var zero = ts.createNode(7 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createNode(160 /* VoidExpression */); + result.expression = zero; + return result; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value); + var equals = ts.createNode(163 /* BinaryExpression */); + equals.left = value; + equals.operator = 30 /* EqualsEqualsEqualsToken */; + equals.right = createVoidZero(); + var cond = ts.createNode(164 /* ConditionalExpression */); + cond.condition = equals; + cond.whenTrue = defaultValue; + cond.whenFalse = value; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createNode(7 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function parenthesizeForAccess(expr) { + if (expr.kind === 64 /* Identifier */ || expr.kind === 149 /* PropertyAccessExpression */ || expr.kind === 150 /* ElementAccessExpression */) { + return expr; + } + var node = ts.createNode(155 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function createPropertyAccess(object, propName) { + if (propName.kind !== 64 /* Identifier */) { + return createElementAccess(object, propName); + } + var node = ts.createNode(149 /* PropertyAccessExpression */); + node.expression = parenthesizeForAccess(object); + node.name = propName; + return node; + } + function createElementAccess(object, index) { + var node = ts.createNode(150 /* ElementAccessExpression */); + node.expression = parenthesizeForAccess(object); + node.argumentExpression = index; + return node; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 204 /* PropertyAssignment */ || p.kind === 205 /* ShorthandPropertyAssignment */) { + var propName = (p.name); + emitDestructuringAssignment(p.initializer || propName, createPropertyAccess(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 167 /* OmittedExpression */) { + emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 163 /* BinaryExpression */ && target.operator === 52 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 148 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 147 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value); + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (root.parent.kind === 172 /* ExpressionStatement */) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 155 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 155 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + if (pattern.kind === 144 /* ObjectBindingPattern */) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccess(value, propName)); + } + else if (element.kind !== 167 /* OmittedExpression */) { + emitBindingElement(element, createElementAccess(value, createNumericLiteral(i))); + } + } + } + else { + emitAssignment(target.name, value); + } + } + } function emitVariableDeclaration(node) { emitLeadingComments(node); - emitModuleMemberName(node); - emitOptional(" = ", node.initializer); + if (ts.isBindingPattern(node.name)) { + emitDestructuring(node); + } + else { + emitModuleMemberName(node); + emitOptional(" = ", node.initializer); + } emitTrailingComments(node); } function emitVariableStatement(node) { @@ -8413,30 +9676,48 @@ var ts; write("var "); } } - emitCommaList(node.declarations, false); + emitCommaList(node.declarations); write(";"); emitTrailingComments(node); } function emitParameter(node) { emitLeadingComments(node); - emit(node.name); + if (ts.isBindingPattern(node.name)) { + var name = createTempVariable(node); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name); + emit(name); + } + else { + emit(node.name); + } emitTrailingComments(node); } function emitDefaultValueAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.initializer) { + var tempIndex = 0; + ts.forEach(node.parameters, function (p) { + if (ts.isBindingPattern(p.name)) { writeLine(); - emitStart(param); + write("var "); + emitDestructuring(p, tempParameters[tempIndex]); + write(";"); + tempIndex++; + } + else if (p.initializer) { + writeLine(); + emitStart(p); write("if ("); - emitNode(param.name); + emitNode(p.name); write(" === void 0)"); - emitEnd(param); + emitEnd(p); write(" { "); - emitStart(param); - emitNode(param.name); + emitStart(p); + emitNode(p.name); write(" = "); - emitNode(param.initializer); - emitEnd(param); + emitNode(p.initializer); + emitEnd(p); write("; }"); } }); @@ -8445,6 +9726,7 @@ var ts; if (ts.hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; + var tempName = createTempVariable(node, true).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -8456,22 +9738,22 @@ var ts; writeLine(); write("for ("); emitStart(restParam); - write("var _i = " + restIndex + ";"); + write("var " + tempName + " = " + restIndex + ";"); emitEnd(restParam); write(" "); emitStart(restParam); - write("_i < arguments.length;"); + write(tempName + " < arguments.length;"); emitEnd(restParam); write(" "); emitStart(restParam); - write("_i++"); + write(tempName + "++"); emitEnd(restParam); write(") {"); increaseIndent(); writeLine(); emitStart(restParam); emitNode(restParam.name); - write("[_i - " + restIndex + "] = arguments[_i];"); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); writeLine(); @@ -8480,7 +9762,7 @@ var ts; } function emitAccessor(node) { emitLeadingComments(node); - write(node.kind === 127 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 130 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); emitTrailingComments(node); @@ -8489,15 +9771,15 @@ var ts; if (!node.body) { return emitPinnedOrTripleSlashComments(node); } - if (node.kind !== 125 /* Method */) { + if (node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { emitLeadingComments(node); } write("function "); - if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) { + if (node.kind === 190 /* FunctionDeclaration */ || (node.kind === 156 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); - if (node.kind !== 125 /* Method */) { + if (node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { emitTrailingComments(node); } } @@ -8513,39 +9795,47 @@ var ts; increaseIndent(); write("("); if (node) { - emitCommaList(node.parameters, false, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); + emitCommaList(node.parameters, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); } write(")"); decreaseIndent(); } function emitSignatureAndBody(node) { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; emitSignatureParameters(node); write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 169 /* Block */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 169 /* Block */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); write("return "); emitNode(node.body); emitEnd(node.body); - write("; "); + write(";"); + emitTempDeclarations(false); + write(" "); emitStart(node.body); write("}"); emitEnd(node.body); } else { - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -8556,11 +9846,12 @@ var ts; write(";"); emitTrailingComments(node.body); } + emitTempDeclarations(true); writeLine(); - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 169 /* Block */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); - emitToken(14 /* CloseBraceToken */, node.body.statements.end); + emitToken(15 /* CloseBraceToken */, node.body.statements.end); } else { decreaseIndent(); @@ -8579,15 +9870,18 @@ var ts; emitEnd(node); write(";"); } + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 165 /* ExpressionStatement */) { + if (statement && statement.kind === 172 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 147 /* CallExpression */) { - var func = expr.func; - if (func && func.kind === 89 /* SuperKeyword */) { + if (expr && expr.kind === 151 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 90 /* SuperKeyword */) { return statement; } } @@ -8610,12 +9904,15 @@ var ts; } }); } - function emitMemberAccess(memberName) { - if (memberName.kind === 7 /* StringLiteral */ || memberName.kind === 6 /* NumericLiteral */) { + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { write("["); emitNode(memberName); write("]"); } + else if (memberName.kind === 122 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } else { write("."); emitNode(memberName); @@ -8623,7 +9920,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 124 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { + if (member.kind === 126 /* PropertyDeclaration */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -8634,7 +9931,7 @@ var ts; else { write("this"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emit(member.initializer); @@ -8646,7 +9943,7 @@ var ts; } function emitMemberFunctions(node) { ts.forEach(node.members, function (member) { - if (member.kind === 125 /* Method */) { + if (member.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */) { if (!member.body) { return emitPinnedOrTripleSlashComments(member); } @@ -8658,7 +9955,7 @@ var ts; if (!(member.flags & 128 /* Static */)) { write(".prototype"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emitStart(member); @@ -8668,7 +9965,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) { + else if (member.kind === 130 /* GetAccessor */ || member.kind === 131 /* SetAccessor */) { var accessors = getAllAccessorDeclarations(node, member); if (member === accessors.firstAccessor) { writeLine(); @@ -8723,19 +10020,20 @@ var ts; write("var "); emit(node.name); write(" = (function ("); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { write("_super"); } write(") {"); increaseIndent(); scopeEmitStart(node); - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("__extends("); emit(node.name); write(", _super);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } writeLine(); emitConstructorOfClass(); @@ -8746,16 +10044,16 @@ var ts; write("return "); emitNode(node.name); } - emitToken(14 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); + emitToken(15 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); write(";"); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); + emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); - if (node.baseType) { - emit(node.baseType.typeName); + if (baseTypeNode) { + emit(baseTypeNode.typeName); } write(");"); emitEnd(node); @@ -8770,8 +10068,14 @@ var ts; } emitTrailingComments(node); function emitConstructorOfClass() { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && !member.body) { + if (member.kind === 129 /* Constructor */ && !member.body) { emitPinnedOrTripleSlashComments(member); } }); @@ -8793,7 +10097,7 @@ var ts; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); - if (node.baseType) { + if (baseTypeNode) { var superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); @@ -8803,11 +10107,11 @@ var ts; emitParameterPropertyAssignments(ctor); } else { - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("_super.apply(this, arguments);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } } emitMemberAssignments(node, 0); @@ -8817,17 +10121,21 @@ var ts; statements = statements.slice(1); emitLines(statements); } + emitTempDeclarations(true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(14 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { emitTrailingComments(ctor); } + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; } } function emitInterfaceDeclaration(node) { @@ -8858,7 +10166,7 @@ var ts; emitEnumMemberDeclarations(isConstEnum); decreaseIndent(); writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); + emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -8903,7 +10211,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 195 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -8926,8 +10234,14 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 193 /* ModuleBlock */) { + if (node.body.kind === 196 /* ModuleBlock */) { + var saveTempCount = tempCount; + var saveTempVariables = tempVariables; + tempCount = 0; + tempVariables = undefined; emit(node.body); + tempCount = saveTempCount; + tempVariables = saveTempVariables; } else { write("{"); @@ -8939,7 +10253,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(14 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -8960,7 +10274,7 @@ var ts; emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (ts.isExternalModuleImportDeclaration(node) && node.parent.kind === 207 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -8981,15 +10295,16 @@ var ts; write("var "); emitModuleMemberName(node); write(" = "); - if (node.entityName) { - emit(node.entityName); + if (ts.isInternalModuleImportDeclaration(node)) { + emit(node.moduleReference); } else { + var literal = ts.getExternalModuleImportDeclarationExpression(node); write("require("); - emitStart(node.externalModuleName); - emitLiteral(node.externalModuleName); - emitEnd(node.externalModuleName); - emitToken(16 /* CloseParenToken */, node.externalModuleName.end); + emitStart(literal); + emitLiteral(literal); + emitEnd(literal); + emitToken(17 /* CloseParenToken */, literal.end); } write(";"); emitEnd(node); @@ -8999,16 +10314,16 @@ var ts; } function getExternalImportDeclarations(node) { var result = []; - ts.forEach(node.statements, function (stat) { - if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { - result.push(stat); + ts.forEach(node.statements, function (statement) { + if (ts.isExternalModuleImportDeclaration(statement) && resolver.isReferencedImportDeclaration(statement)) { + result.push(statement); } }); return result; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 198 /* ExportAssignment */) { return node; } }); @@ -9023,7 +10338,7 @@ var ts; write("[\"require\", \"exports\""); ts.forEach(imports, function (imp) { write(", "); - emitLiteral(imp.externalModuleName); + emitLiteral(ts.getExternalModuleImportDeclarationExpression(imp)); }); ts.forEach(node.amdDependencies, function (amdDependency) { var text = "\"" + amdDependency + "\""; @@ -9119,6 +10434,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); } + emitLeadingComments(node.endOfFileToken); } function emitNode(node) { if (!node) { @@ -9128,129 +10444,144 @@ var ts; return emitPinnedOrTripleSlashComments(node); } switch (node.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: return emitIdentifier(node); - case 123 /* Parameter */: + case 124 /* Parameter */: return emitParameter(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return emitMethod(node); + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return emitAccessor(node); - case 91 /* ThisKeyword */: + case 92 /* ThisKeyword */: return emitThis(node); - case 89 /* SuperKeyword */: + case 90 /* SuperKeyword */: return emitSuper(node); - case 87 /* NullKeyword */: + case 88 /* NullKeyword */: return write("null"); - case 93 /* TrueKeyword */: + case 94 /* TrueKeyword */: return write("true"); - case 78 /* FalseKeyword */: + case 79 /* FalseKeyword */: return write("false"); - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 8 /* RegularExpressionLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 11 /* TemplateMiddle */: - case 12 /* TemplateTail */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 9 /* RegularExpressionLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 11 /* TemplateHead */: + case 12 /* TemplateMiddle */: + case 13 /* TemplateTail */: return emitLiteral(node); - case 158 /* TemplateExpression */: + case 165 /* TemplateExpression */: return emitTemplateExpression(node); - case 159 /* TemplateSpan */: + case 168 /* TemplateSpan */: return emitTemplateSpan(node); case 121 /* QualifiedName */: - return emitPropertyAccess(node); - case 141 /* ArrayLiteral */: + return emitQualifiedName(node); + case 144 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 145 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 147 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 143 /* PropertyAssignment */: + case 204 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 144 /* ShorthandPropertyAssignment */: - return emitShortHandPropertyAssignment(node); - case 145 /* PropertyAccess */: + case 205 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 122 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 149 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 146 /* IndexedAccess */: + case 150 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 147 /* CallExpression */: + case 151 /* CallExpression */: return emitCallExpression(node); - case 148 /* NewExpression */: + case 152 /* NewExpression */: return emitNewExpression(node); - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: - return emit(node.operand); - case 151 /* ParenExpression */: + case 154 /* TypeAssertionExpression */: + return emit(node.expression); + case 155 /* ParenthesizedExpression */: return emitParenExpression(node); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return emitUnaryExpression(node); - case 156 /* BinaryExpression */: + case 158 /* DeleteExpression */: + return emitDeleteExpression(node); + case 159 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 160 /* VoidExpression */: + return emitVoidExpression(node); + case 161 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 162 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 163 /* BinaryExpression */: return emitBinaryExpression(node); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return emitConditionalExpression(node); - case 161 /* OmittedExpression */: + case 167 /* OmittedExpression */: return; - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return emitBlock(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return emitVariableStatement(node); - case 164 /* EmptyStatement */: + case 171 /* EmptyStatement */: return write(";"); - case 165 /* ExpressionStatement */: + case 172 /* ExpressionStatement */: return emitExpressionStatement(node); - case 166 /* IfStatement */: + case 173 /* IfStatement */: return emitIfStatement(node); - case 167 /* DoStatement */: + case 174 /* DoStatement */: return emitDoStatement(node); - case 168 /* WhileStatement */: + case 175 /* WhileStatement */: return emitWhileStatement(node); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return emitForStatement(node); - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return emitForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return emitReturnStatement(node); - case 174 /* WithStatement */: + case 181 /* WithStatement */: return emitWithStatement(node); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return emitSwitchStatement(node); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return emitLabelledStatement(node); - case 179 /* ThrowStatement */: + case 184 /* ThrowStatement */: return emitThrowStatement(node); - case 180 /* TryStatement */: + case 185 /* TryStatement */: return emitTryStatement(node); - case 182 /* CatchBlock */: - return emitCatchBlock(node); - case 184 /* DebuggerStatement */: + case 203 /* CatchClause */: + return emitCatchClause(node); + case 188 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 185 /* VariableDeclaration */: + case 189 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return emitClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return emitImportDeclaration(node); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return emitSourceFile(node); } } @@ -9268,7 +10599,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 207 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -9285,7 +10616,7 @@ var ts; emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 207 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } @@ -9379,17 +10710,11 @@ var ts; writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } - var hasSemanticErrors = resolver.hasSemanticErrors(); - var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); - function emitFile(jsFilePath, sourceFile) { - if (!isEmitBlocked) { - emitJavaScript(jsFilePath, sourceFile); - if (!hasSemanticErrors && compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); - } - } - } + var hasSemanticErrors = false; + var isEmitBlocked = false; if (targetSourceFile === undefined) { + hasSemanticErrors = resolver.hasSemanticErrors(); + isEmitBlocked = resolver.isEmitBlocked(); ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); @@ -9402,13 +10727,29 @@ var ts; } else { if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile); + isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) { + hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile); + isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile); + } + }); emitFile(compilerOptions.out); } } + function emitFile(jsFilePath, sourceFile) { + if (!isEmitBlocked) { + emitJavaScript(jsFilePath, sourceFile); + if (!hasSemanticErrors && compilerOptions.declaration) { + writeDeclarationFile(jsFilePath, sourceFile); + } + } + } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); var hasEmitterError = ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1 /* Error */; }); @@ -9441,44 +10782,6 @@ var ts; var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - for (var i = 0; i < declarations.length; i++) { - var declaration = declarations[i]; - if (declaration.kind === kind) { - return declaration; - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length == 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - clear: function () { return str = ""; }, - trackSymbol: function () { - } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -9499,9 +10802,7 @@ var ts; getDiagnostics: getDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - checkProgram: checkProgram, - getParentOfSymbol: getParentOfSymbol, - getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol, + getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -9509,9 +10810,9 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, - getSymbolInfo: getSymbolInfo, + getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeOfNode: getTypeOfNode, + getTypeAtLocation: getTypeAtLocation, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -9528,17 +10829,17 @@ var ts; hasEarlyErrors: hasEarlyErrors, isEmitBlocked: isEmitBlocked }; - var undefinedSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "arguments"); - var unknownSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(268435456 /* Transient */, "__resolving__"); + var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 131072 /* Unwidened */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 131072 /* Unwidened */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var resolvingType = createIntrinsicType(1 /* Any */, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -9557,6 +10858,7 @@ var ts; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; + var anyArrayType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -9591,13 +10893,13 @@ var ts; if (flags & 16 /* Function */) result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 3258879 /* ClassExcludes */; + result |= 899583 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 3152288 /* InterfaceExcludes */; + result |= 792992 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 3258623 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 3259263 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 106639 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) @@ -9606,12 +10908,12 @@ var ts; result |= 41919 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) result |= 74687 /* SetAccessorExcludes */; - if (flags & 1048576 /* TypeParameter */) - result |= 2103776 /* TypeParameterExcludes */; - if (flags & 2097152 /* TypeAlias */) - result |= 3152352 /* TypeAliasExcludes */; - if (flags & 33554432 /* Import */) - result |= 33554432 /* ImportExcludes */; + if (flags & 262144 /* TypeParameter */) + result |= 530912 /* TypeParameterExcludes */; + if (flags & 524288 /* TypeAlias */) + result |= 793056 /* TypeAliasExcludes */; + if (flags & 8388608 /* Import */) + result |= 8388608 /* ImportExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -9620,7 +10922,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 134217728 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -9684,7 +10986,7 @@ var ts; } else { var symbol = target[id]; - if (!(symbol.flags & 134217728 /* Merged */)) { + if (!(symbol.flags & 33554432 /* Merged */)) { target[id] = symbol = cloneSymbol(symbol); } extendSymbol(symbol, source[id]); @@ -9693,7 +10995,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 268435456 /* Transient */) + if (symbol.flags & 67108864 /* Transient */) return symbol; if (!symbol.id) symbol.id = nextSymbolId++; @@ -9705,19 +11007,19 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 197 /* SourceFile */); + return ts.getAncestor(node, 207 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 207 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { var target = resolveImport(symbol); if (target === unknownSymbol || target.flags & meaning) { return symbol; @@ -9749,21 +11051,22 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { + case 195 /* ModuleDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { break loop; } break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 124 /* Property */: - if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + if (location.parent.kind === 191 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -9772,9 +11075,9 @@ var ts; } } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; @@ -9782,18 +11085,19 @@ var ts; break loop; } break; - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 152 /* FunctionExpression */: + case 156 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9804,8 +11108,8 @@ var ts; break loop; } break; - case 182 /* CatchBlock */: - var id = location.variable; + case 203 /* CatchClause */: + var id = location.name; if (name === id.text) { result = location.symbol; break loop; @@ -9841,12 +11145,12 @@ var ts; return result; } function resolveImport(symbol) { - ts.Debug.assert((symbol.flags & 33554432 /* Import */) !== 0, "Should only get Imports here."); + ts.Debug.assert((symbol.flags & 8388608 /* Import */) !== 0, "Should only get Imports here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */); - var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); + var node = ts.getDeclarationOfKind(symbol, 197 /* ImportDeclaration */); + var target = node.moduleReference.kind === 199 /* ExternalModuleReference */ ? resolveExternalModuleName(node, ts.getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -9861,25 +11165,28 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */); + importDeclaration = ts.getAncestor(entityName, 197 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 64 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + if (entityName.kind === 64 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */); - return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); + ts.Debug.assert(entityName.parent.kind === 197 /* ImportDeclaration */); + return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { - if (name.kind === 63 /* Identifier */) { + if (ts.getFullWidth(name) === 0) { + return undefined; + } + if (name.kind === 64 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; @@ -9887,7 +11194,7 @@ var ts; } else if (name.kind === 121 /* QualifiedName */) { var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); - if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) + if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -9895,18 +11202,19 @@ var ts; return; } } - else { - return; - } - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } - function resolveExternalModuleName(location, moduleLiteral) { + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).filename); - var moduleName = moduleLiteral.text; + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); if (!moduleName) return; var isRelative = isExternalModuleNameRelative(moduleName); @@ -9930,18 +11238,18 @@ var ts; if (sourceFile.symbol) { return getResolvedExportSymbol(sourceFile.symbol); } - error(moduleLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); return; } - error(moduleLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); if (symbol) { - if (symbol.flags & (107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */)) { + if (symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) { return symbol; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return resolveImport(symbol); } } @@ -9965,7 +11273,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } if (node.exportName.text) { - var meaning = 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */; + var meaning = 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */; var exportSymbol = resolveName(node, node.exportName.text, meaning, ts.Diagnostics.Cannot_find_name_0, node.exportName); } } @@ -9976,9 +11284,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 207 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 198 /* ExportAssignment */) { result.push(node); } else { @@ -10002,16 +11310,16 @@ var ts; return getMergedSymbol(symbol.parent); } function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 4194304 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; + return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { return symbolIsValue(getSymbolLinks(symbol).target); } if (symbol.flags & 107455 /* Value */) { return true; } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return (resolveImport(symbol).flags & 107455 /* Value */) !== 0; } return false; @@ -10020,7 +11328,7 @@ var ts; var members = node.members; for (var i = 0; i < members.length; i++) { var member = members[i]; - if (member.kind === 126 /* Constructor */ && member.body) { + if (member.kind === 129 /* Constructor */ && member.body) { return member; } } @@ -10073,9 +11381,6 @@ var ts; function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; - } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; for (var location = enclosingDeclaration; location; location = location.parent) { @@ -10085,17 +11390,17 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -10125,8 +11430,8 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 33554432 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (symbolFromSymbolTable.flags & 8388608 /* Import */) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportDeclaration)) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -10153,7 +11458,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 33554432 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -10163,7 +11468,7 @@ var ts; return qualify; } function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { @@ -10208,7 +11513,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 195 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || (declaration.kind === 207 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10218,7 +11523,7 @@ var ts; return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 197 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -10237,51 +11542,44 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 135 /* TypeQuery */) { - meaning = 107455 /* Value */ | 4194304 /* ExportValue */; + if (entityName.parent.kind === 138 /* TypeQuery */) { + meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) { + else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 197 /* ImportDeclaration */) { meaning = 1536 /* Namespace */; } else { - meaning = 3152352 /* Type */; + meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return hasVisibleDeclarations(symbol) || { + return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } function writeKeyword(writer, kind) { writer.writeKeyword(ts.tokenToString(kind)); } function writePunctuation(writer, kind) { writer.writePunctuation(ts.tokenToString(kind)); } - function writeOperator(writer, kind) { - writer.writeOperator(ts.tokenToString(kind)); - } function writeSpace(writer) { writer.writeSpace(" "); } function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); return result; } function typeToString(type, enclosingDeclaration, flags) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { result = result.substr(0, maxLength - "...".length) + "..."; @@ -10291,10 +11589,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 140 /* ParenType */) { + while (node.kind === 143 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 190 /* TypeAliasDeclaration */) { + if (node.kind === 193 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -10317,14 +11615,14 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 19 /* DotToken */); + writePunctuation(writer, 20 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -10352,7 +11650,7 @@ var ts; } } } - if (enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { + if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { walkSymbol(symbol, meaning); return; } @@ -10369,7 +11667,7 @@ var ts; writeTypeReference(type, flags); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 3152352 /* Type */); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); @@ -10384,11 +11682,11 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 20 /* DotDotDotToken */); + writePunctuation(writer, 21 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); } } function writeTypeList(types, union) { @@ -10397,7 +11695,7 @@ var ts; if (union) { writeSpace(writer); } - writePunctuation(writer, union ? 43 /* BarToken */ : 22 /* CommaToken */); + writePunctuation(writer, union ? 44 /* BarToken */ : 23 /* CommaToken */); writeSpace(writer); } writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); @@ -10406,28 +11704,28 @@ var ts; function writeTypeReference(type, flags) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(type.typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 17 /* OpenBracketToken */); - writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writePunctuation(writer, 19 /* CloseBracketToken */); } else { - buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 3152352 /* Type */); - writePunctuation(writer, 23 /* LessThanToken */); + buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 793056 /* Type */); + writePunctuation(writer, 24 /* LessThanToken */); writeTypeList(type.typeArguments, false); - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function writeTupleType(type) { - writePunctuation(writer, 17 /* OpenBracketToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); writeTypeList(type.elementTypes, false); - writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 19 /* CloseBracketToken */); } function writeUnionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } writeTypeList(type.types, true); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -10440,10 +11738,10 @@ var ts; else if (typeStack && ts.contains(typeStack, type)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 3152352 /* Type */); + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */); } else { - writeKeyword(writer, 109 /* AnyKeyword */); + writeKeyword(writer, 110 /* AnyKeyword */); } } else { @@ -10457,7 +11755,7 @@ var ts; function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 207 /* SourceFile */ || declaration.parent.kind === 196 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10465,80 +11763,88 @@ var ts; } } function writeTypeofSymbol(type) { - writeKeyword(writer, 95 /* TypeOfKeyword */); + writeKeyword(writer, 96 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 13 /* OpenBraceToken */); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); } - writeKeyword(writer, 86 /* NewKeyword */); + writeKeyword(writer, 87 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } return; } } - writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, 86 /* NewKeyword */); + writeKeyword(writer, 87 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 118 /* StringKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); + writeKeyword(writer, 119 /* StringKeyword */); + writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 18 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 116 /* NumberKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); + writeKeyword(writer, 117 /* NumberKeyword */); + writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { @@ -10548,28 +11854,28 @@ var ts; var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 50 /* QuestionToken */); } buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 50 /* QuestionToken */); } - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); + writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 14 /* CloseBraceToken */); + writePunctuation(writer, 15 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -10583,67 +11889,67 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 77 /* ExtendsKeyword */); + writeKeyword(writer, 78 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writePunctuation(writer, 20 /* DotDotDotToken */); + if (ts.hasDotDotDotToken(p.valueDeclaration)) { + writePunctuation(writer, 21 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writePunctuation(writer, 49 /* QuestionToken */); + if (ts.hasQuestionToken(p.valueDeclaration) || p.valueDeclaration.initializer) { + writePunctuation(writer, 50 /* QuestionToken */); } - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); + writePunctuation(writer, 24 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); + writePunctuation(writer, 24 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 24 /* GreaterThanToken */); + writePunctuation(writer, 25 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, typeStack) { - writePunctuation(writer, 15 /* OpenParenToken */); + writePunctuation(writer, 16 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); + writePunctuation(writer, 23 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 16 /* CloseParenToken */); + writePunctuation(writer, 17 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 31 /* EqualsGreaterThanToken */); + writePunctuation(writer, 32 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 50 /* ColonToken */); + writePunctuation(writer, 51 /* ColonToken */); } writeSpace(writer); buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); @@ -10676,12 +11982,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 192 /* ModuleDeclaration */) { - if (node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 195 /* ModuleDeclaration */) { + if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 197 /* SourceFile */) { + else if (node.kind === 207 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10697,7 +12003,7 @@ var ts; if (isSymbolUsedInExportAssignment(symbolOfNode)) { return true; } - if (symbolOfNode.flags & 33554432 /* Import */) { + if (symbolOfNode.flags & 8388608 /* Import */) { return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode)); } } @@ -10705,17 +12011,17 @@ var ts; if (exportAssignmentSymbol === symbol) { return true; } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 33554432 /* Import */)) { + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Import */)) { resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol); if (resolvedExportSymbol === symbol) { return true; } - return ts.forEach(resolvedExportSymbol.declarations, function (declaration) { - while (declaration) { - if (declaration === node) { + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { return true; } - declaration = declaration.parent; + current = current.parent; } }); } @@ -10723,33 +12029,46 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 185 /* VariableDeclaration */: - case 192 /* ModuleDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 186 /* FunctionDeclaration */: - case 191 /* EnumDeclaration */: - case 194 /* ImportDeclaration */: - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 195 /* ModuleDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 190 /* FunctionDeclaration */: + case 194 /* EnumDeclaration */: + case 197 /* ImportDeclaration */: + var parent = getDeclarationContainer(node); + if (!(node.flags & 1 /* Export */) && !(node.kind !== 197 /* ImportDeclaration */ && parent.kind !== 207 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); - case 124 /* Property */: - case 125 /* Method */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; } - case 126 /* Constructor */: - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: - case 123 /* Parameter */: - case 193 /* ModuleBlock */: - case 122 /* TypeParameter */: + case 129 /* Constructor */: + case 133 /* ConstructSignature */: + case 132 /* CallSignature */: + case 134 /* IndexSignature */: + case 124 /* Parameter */: + case 196 /* ModuleBlock */: + case 123 /* TypeParameter */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 139 /* TypeLiteral */: + case 135 /* TypeReference */: + case 140 /* ArrayType */: + case 141 /* TupleType */: + case 142 /* UnionType */: + case 143 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - case 197 /* SourceFile */: + case 207 /* SourceFile */: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10763,21 +12082,71 @@ var ts; return links.isVisible; } } + function getRootDeclaration(node) { + while (node.kind === 146 /* BindingElement */) { + node = node.parent.parent; + } + return node; + } + function getDeclarationContainer(node) { + node = getRootDeclaration(node); + return node.kind === 189 /* VariableDeclaration */ ? node.parent.parent : node.parent; + } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } - function getTypeOfVariableOrPropertyDeclaration(declaration) { - if (declaration.parent.kind === 170 /* ForInStatement */) { + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + if (parentType === unknownType) { + return unknownType; + } + if (!parentType || parentType === anyType) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + if (pattern.kind === 144 /* ObjectBindingPattern */) { + var name = declaration.propertyName || declaration.name; + var type = getTypeOfPropertyOfType(parentType, name.text) || isNumericName(name.text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); + return unknownType; + } + return type; + } + if (!isTypeAssignableTo(parentType, anyArrayType)) { + error(pattern, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(parentType)); + return unknownType; + } + var propName = "" + ts.indexOf(pattern.elements, declaration); + var type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : getIndexTypeOfType(parentType, 1 /* Number */); + if (!type) { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + return unknownType; + } + return type; + } + function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.parent.kind === 177 /* ForInStatement */) { return anyType; } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 123 /* Parameter */) { + if (declaration.kind === 124 /* Parameter */) { var func = declaration.parent; - if (func.kind === 128 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); + if (func.kind === 131 /* SetAccessor */ && !ts.hasComputedNameButNotSymbol(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 130 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10788,58 +12157,68 @@ var ts; } } if (declaration.initializer) { - var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 143 /* PropertyAssignment */) { - var unwidenedType = type; - type = getWidenedType(type); - if (type !== unwidenedType) { - checkImplicitAny(type); - } + return checkExpressionCached(declaration.initializer); + } + if (declaration.kind === 205 /* ShorthandPropertyAssignment */) { + return checkIdentifier(declaration.name); + } + return undefined; + } + function getTypeFromBindingElement(element) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name); + } + return anyType; + } + function getTypeFromBindingPattern(pattern) { + if (pattern.kind === 145 /* ArrayBindingPattern */) { + return createTupleType(ts.map(pattern.elements, function (e) { return e.kind === 167 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e); })); + } + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e); + members[symbol.name] = symbol; + }); + return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + } + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); } - return type; + return declaration.kind !== 204 /* PropertyAssignment */ ? getWidenedType(type) : type; } - if (declaration.kind === 144 /* ShorthandPropertyAssignment */) { - var type = checkIdentifier(declaration.name); - return type; + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } + type = declaration.dotDotDotToken ? anyArrayType : anyType; + if (reportErrors && compilerOptions.noImplicitAny) { + var root = getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 124 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } } - var type = declaration.flags & 8 /* Rest */ ? createArrayType(anyType) : anyType; - checkImplicitAny(type); return type; - function checkImplicitAny(type) { - if (!fullTypeCheck || !compilerOptions.noImplicitAny) { - return; - } - if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) { - return; - } - if (isPrivateWithinAmbient(declaration) || (declaration.kind === 123 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { - return; - } - switch (declaration.kind) { - case 124 /* Property */: - var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 123 /* Parameter */: - var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - default: - var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeToString(type)); - } } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 536870912 /* Prototype */) { + if (symbol.flags & 134217728 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 182 /* CatchBlock */) { + if (declaration.kind === 203 /* CatchClause */) { return links.type = anyType; } links.type = resolvingType; - var type = getTypeOfVariableOrPropertyDeclaration(declaration); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); if (links.type === resolvingType) { links.type = type; } @@ -10858,7 +12237,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 127 /* GetAccessor */) { + if (accessor.kind === 130 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -10877,8 +12256,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 130 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 131 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10908,7 +12287,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 130 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -10942,7 +12321,7 @@ var ts; return links.type; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -10957,7 +12336,7 @@ var ts; if (symbol.flags & 98304 /* Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return getTypeOfImport(symbol); } return unknownType; @@ -10975,7 +12354,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */ || node.kind === 191 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -11006,9 +12385,10 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */); - if (declaration.baseType) { - var baseType = getTypeFromTypeReferenceNode(declaration.baseType); + var declaration = ts.getDeclarationOfKind(symbol, 191 /* ClassDeclaration */); + var baseTypeNode = ts.getClassBaseTypeNode(declaration); + if (baseTypeNode) { + var baseType = getTypeFromTypeReferenceNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -11019,7 +12399,7 @@ var ts; } } else { - error(declaration.baseType, ts.Diagnostics.A_class_may_only_extend_another_class); + error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); } } } @@ -11046,8 +12426,8 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) { - ts.forEach(declaration.baseTypes, function (node) { + if (declaration.kind === 192 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -11077,7 +12457,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 193 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -11085,7 +12465,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 193 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -11104,7 +12484,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 123 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11119,23 +12499,23 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0); + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & 32 /* Class */) { return getDeclaredTypeOfClass(symbol); } if (symbol.flags & 64 /* Interface */) { return getDeclaredTypeOfInterface(symbol); } - if (symbol.flags & 2097152 /* TypeAlias */) { + if (symbol.flags & 524288 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } if (symbol.flags & 384 /* Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 1048576 /* TypeParameter */) { + if (symbol.flags & 262144 /* TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { return getDeclaredTypeOfImport(symbol); } return unknownType; @@ -11237,7 +12617,7 @@ var ts; function createTupleTypeMemberSymbols(memberTypes) { var members = {}; for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "" + i); + var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); symbol.type = memberTypes[i]; members[i] = symbol; } @@ -11434,7 +12814,7 @@ var ts; } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 268435456 /* Transient */ | 1073741824 /* UnionProperty */, name); + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* UnionProperty */, name); result.unionType = unionType; result.declarations = declarations; result.type = getUnionType(propTypes); @@ -11507,7 +12887,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 126 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 129 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; var hasStringLiterals = false; @@ -11515,11 +12895,11 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 7 /* StringLiteral */) { + if (param.type && param.type.kind === 8 /* StringLiteral */) { hasStringLiterals = true; } if (minArgumentCount < 0) { - if (param.initializer || param.flags & (4 /* QuestionMark */ | 8 /* Rest */)) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { minArgumentCount = i; } } @@ -11535,8 +12915,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 127 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); + if (declaration.kind === 130 /* GetAccessor */ && !ts.hasComputedNameButNotSymbol(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 131 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11554,18 +12934,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 126 /* Constructor */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11634,7 +13015,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 126 /* Constructor */ || signature.declaration.kind === 130 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 129 /* Constructor */ || signature.declaration.kind === 133 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -11648,7 +13029,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 116 /* NumberKeyword */ : 118 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 117 /* NumberKeyword */ : 119 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11675,7 +13056,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 123 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11696,11 +13077,15 @@ var ts; return result; } } + function getUnwidenedFlagOfTypes(types) { + return ts.forEach(types, function (t) { return t.flags & 131072 /* Unwidened */; }) || 0; + } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - type = target.instantiations[id] = createObjectType(4096 /* Reference */, target.symbol); + var flags = 4096 /* Reference */ | getUnwidenedFlagOfTypes(typeArguments); + type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; } @@ -11715,17 +13100,17 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 122 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 123 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 132 /* TypeReference */ && n.typeName.kind === 63 /* Identifier */) { + if (n.kind === 135 /* TypeReference */ && n.typeName.kind === 64 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 3152352 /* Type */, undefined, undefined); - if (symbol && (symbol.flags & 1048576 /* TypeParameter */)) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); } } @@ -11743,10 +13128,10 @@ var ts; function getTypeFromTypeReferenceNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var symbol = resolveEntityName(node, node.typeName, 3152352 /* Type */); + var symbol = resolveEntityName(node, node.typeName, 793056 /* Type */); if (symbol) { var type; - if ((symbol.flags & 1048576 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { type = unknownType; } else { @@ -11776,7 +13161,7 @@ var ts; function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); + links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); } return links.resolvedType; } @@ -11786,9 +13171,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: return declaration; } } @@ -11808,7 +13193,7 @@ var ts; return type; } function getGlobalSymbol(name) { - return resolveName(undefined, name, 3152352 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); + return resolveName(undefined, name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); } function getGlobalType(name) { return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0); @@ -11916,7 +13301,7 @@ var ts; var id = getTypeListId(sortedTypes); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getUnwidenedFlagOfTypes(sortedTypes)); type.types = sortedTypes; } return type; @@ -11936,8 +13321,9 @@ var ts; return links.resolvedType; } function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) + if (ts.hasProperty(stringLiteralTypes, node.text)) { return stringLiteralTypes[node.text]; + } var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); type.text = ts.getTextOfNode(node); return type; @@ -11951,35 +13337,35 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 109 /* AnyKeyword */: + case 110 /* AnyKeyword */: return anyType; - case 118 /* StringKeyword */: + case 119 /* StringKeyword */: return stringType; - case 116 /* NumberKeyword */: + case 117 /* NumberKeyword */: return numberType; - case 110 /* BooleanKeyword */: + case 111 /* BooleanKeyword */: return booleanType; - case 97 /* VoidKeyword */: + case 98 /* VoidKeyword */: return voidType; - case 7 /* StringLiteral */: + case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return getTypeFromTypeReferenceNode(node); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 138 /* TupleType */: + case 141 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 139 /* UnionType */: + case 142 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 136 /* TypeLiteral */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 139 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 63 /* Identifier */: + case 64 /* Identifier */: case 121 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); @@ -12074,12 +13460,12 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 67108864 /* Instantiated */) { + if (symbol.flags & 16777216 /* Instantiated */) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(67108864 /* Instantiated */ | 268435456 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -12123,22 +13509,31 @@ var ts; } return type; } - function isContextSensitiveExpression(node) { + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 142 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 143 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 141 /* ArrayLiteral */: - return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 157 /* ConditionalExpression */: - return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 156 /* BinaryExpression */: - return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 148 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 147 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 164 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); + case 163 /* BinaryExpression */: + return node.operator === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 204 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return isContextSensitiveFunctionLikeDeclaration(node); } return false; } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); + } function getTypeWithoutConstructors(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); @@ -12204,13 +13599,9 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (relation === identityRelation) { - if (source === target) - return -1 /* True */; - } - else { - if (source === target) - return -1 /* True */; + if (source === target) + return -1 /* True */; + if (relation !== identityRelation) { if (target.flags & 1 /* Any */) return -1 /* True */; if (source === undefinedType) @@ -12228,14 +13619,37 @@ var ts; return -1 /* True */; } } - if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; + if (source.flags & 16384 /* Union */ || target.flags & 16384 /* Union */) { + if (relation === identityRelation) { + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToUnionType(source, target)) { + if (result &= unionTypeRelatedToUnionType(target, source)) { + return result; + } + } + } + else if (source.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else { + if (result = unionTypeRelatedToType(target, source, reportErrors)) { + return result; + } + } } - } - else if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; + else { + if (source.flags & 16384 /* Union */) { + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else { + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; + } + } } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { @@ -12263,6 +13677,18 @@ var ts; } return 0 /* False */; } + function unionTypeRelatedToUnionType(source, target) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = typeRelatedToUnionType(sourceTypes[i], target, false); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { @@ -12325,7 +13751,7 @@ var ts; if (overflow) { return 0 /* False */; } - var id = source.id + "," + target.id; + var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related ? -1 /* True */ : 0 /* False */; @@ -12415,14 +13841,14 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (relation === subtypeRelation || !isOptionalProperty(targetProp)) { + if (relation === subtypeRelation || !(targetProp.flags & 536870912 /* Optional */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0 /* False */; } } - else if (!(targetProp.flags & 536870912 /* Prototype */)) { + else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetFlags = getDeclarationFlagsFromSymbol(targetProp); if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { @@ -12463,7 +13889,7 @@ var ts; return 0 /* False */; } result &= related; - if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { + if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -12679,7 +14105,7 @@ var ts; } } else { - if (isOptionalProperty(sourceProp) !== isOptionalProperty(targetProp)) { + if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { return 0 /* False */; } } @@ -12766,74 +14192,108 @@ var ts; function isArrayType(type) { return type.flags & 4096 /* Reference */ && type.target === globalArrayType; } - function getInnermostTypeOfNestedArrayTypes(type) { - while (isArrayType(type)) { - type = type.typeArguments[0]; + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = getWidenedType(getTypeOfSymbol(p)); + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + members[symbol.name] = symbol; + }); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 131072 /* Unwidened */) { + if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { + return anyType; + } + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.map(type.types, function (t) { return getWidenedType(t); })); + } + if (isTypeOfObjectLiteral(type)) { + return getWidenedTypeOfObjectLiteral(type); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } } return type; } - function getWidenedType(type, suppressNoImplicitAnyErrors) { - if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { - return anyType; - } + function reportWideningErrorsInType(type) { if (type.flags & 16384 /* Union */) { - return getWidenedTypeOfUnion(type); - } - if (isTypeOfObjectLiteral(type)) { - return getWidenedTypeOfObjectLiteral(type); + var errorReported = false; + ts.forEach(type.types, function (t) { + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + }); + return errorReported; } if (isArrayType(type)) { - return getWidenedTypeOfArrayLiteral(type); + return reportWideningErrorsInType(type.typeArguments[0]); } - return type; - function getWidenedTypeOfUnion(type) { - return getUnionType(ts.map(type.types, function (t) { return getWidenedType(t, suppressNoImplicitAnyErrors); })); - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - if (properties.length) { - var widenedTypes = []; - var propTypeWasWidened = false; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - propTypeWasWidened = true; - if (!suppressNoImplicitAnyErrors && compilerOptions.noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType)); - } + if (isTypeOfObjectLiteral(type)) { + var errorReported = false; + ts.forEach(getPropertiesOfObjectType(type), function (p) { + var t = getTypeOfSymbol(p); + if (t.flags & 131072 /* Unwidened */) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } - widenedTypes.push(widenedType); - }); - if (propTypeWasWidened) { - var members = {}; - var index = 0; - ts.forEach(properties, function (p) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */ | p.flags, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedTypes[index++]; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - members[symbol.name] = symbol; - }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + errorReported = true; } - } - return type; + }); + return errorReported; } - function getWidenedTypeOfArrayLiteral(type) { - var elementType = type.typeArguments[0]; - var widenedType = getWidenedType(elementType, suppressNoImplicitAnyErrors); - type = elementType !== widenedType ? createArrayType(widenedType) : type; - return type; + return false; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + switch (declaration.kind) { + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 124 /* Parameter */: + var diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + var diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (fullTypeCheck && compilerOptions.noImplicitAny && type.flags & 131072 /* Unwidened */) { + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } } } function forEachMatchingParameterType(source, target, callback) { @@ -13035,16 +14495,16 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = (ts.getFullWidth(node) > 0 && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return true; - case 63 /* Identifier */: + case 64 /* Identifier */: case 121 /* QualifiedName */: node = node.parent; continue; @@ -13063,6 +14523,9 @@ var ts; } return type; } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } function isVariableAssignedWithin(symbol, node) { var links = getNodeLinks(node); if (links.assignmentChecks) { @@ -13076,99 +14539,129 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { + if (node.operator >= 52 /* FirstAssignment */ && node.operator <= 63 /* LastAssignment */) { var n = node.left; - while (n.kind === 151 /* ParenExpression */) { + while (n.kind === 155 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 64 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } return ts.forEachChild(node, isAssignedIn); } function isAssignedInVariableDeclaration(node) { - if (getSymbolOfNode(node) === symbol && node.initializer) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { return true; } return ts.forEachChild(node, isAssignedIn); } function isAssignedIn(node) { switch (node.kind) { - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 185 /* VariableDeclaration */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 161 /* PrefixUnaryExpression */: + case 158 /* DeleteExpression */: + case 159 /* TypeOfExpression */: + case 160 /* VoidExpression */: + case 162 /* PostfixUnaryExpression */: + case 164 /* ConditionalExpression */: + case 169 /* Block */: + case 170 /* VariableStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 180 /* ReturnStatement */: + case 181 /* WithStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; } } + function resolveLocation(node) { + var containerNodes = []; + for (var parent = node.parent; parent; parent = parent.parent) { + if ((ts.isExpression(parent) || ts.isObjectLiteralMethod(node)) && isContextSensitive(parent)) { + containerNodes.unshift(parent); + } + } + ts.forEach(containerNodes, function (node) { + getTypeOfNode(node); + }); + } + function getSymbolAtLocation(node) { + resolveLocation(node); + return getSymbolInfo(node); + } + function getTypeAtLocation(node) { + resolveLocation(node); + return getTypeOfNode(node); + } + function getTypeOfSymbolAtLocation(symbol, node) { + resolveLocation(node); + return getNarrowedTypeOfSymbol(symbol, node); + } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */)) { - loop: while (true) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 166 /* IfStatement */: + case 173 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: if (child === node.right) { - if (node.operator === 47 /* AmpersandAmpersandToken */) { + if (node.operator === 48 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operator === 48 /* BarBarToken */) { + else if (node.operator === 49 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } break; - case 197 /* SourceFile */: - case 192 /* ModuleDeclaration */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: + case 207 /* SourceFile */: + case 195 /* ModuleDeclaration */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: break loop; } if (narrowedType !== type && isTypeSubtypeOf(narrowedType, type)) { @@ -13181,14 +14674,17 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 159 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + return type; + } var left = expr.left; var right = expr.right; - if (left.kind !== 154 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.expression.kind !== 64 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var t = right.text; var checkType = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; - if (expr.operator === 30 /* ExclamationEqualsEqualsToken */) { + if (expr.operator === 31 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { @@ -13221,7 +14717,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 63 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (!assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -13237,25 +14733,25 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: var operator = expr.operator; - if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { + if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 47 /* AmpersandAmpersandToken */) { + else if (operator === 48 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 48 /* BarBarToken */) { + else if (operator === 49 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 85 /* InstanceOfKeyword */) { + else if (operator === 86 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 154 /* PrefixOperator */: - if (expr.operator === 45 /* ExclamationToken */) { + case 161 /* PrefixUnaryExpression */: + if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -13265,18 +14761,17 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol.flags & 33554432 /* Import */) { + if (symbol.flags & 8388608 /* Import */) { getSymbolLinks(symbol).referenced = getSymbolLinks(symbol).referenced || (!isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol))); } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkCollisionWithIndexVariableInGeneratedCode(node, node); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 191 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { + if (container.kind === 126 /* PropertyDeclaration */ || container.kind === 129 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -13286,23 +14781,24 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 153 /* ArrowFunction */) { + if (container.kind === 157 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 126 /* Constructor */: + case 129 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } @@ -13311,7 +14807,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 191 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13324,31 +14820,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node; } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 123 /* Parameter */) { + if (n.kind === 124 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 151 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 191 /* ClassDeclaration */); var baseClass; - if (enclosingClass && enclosingClass.baseType) { + if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); baseClass = classType.baseTypes.length && classType.baseTypes[0]; } @@ -13360,20 +14858,20 @@ var ts; if (container) { var canUseSuperExpression = false; if (isCallExpression) { - canUseSuperExpression = container.kind === 126 /* Constructor */; + canUseSuperExpression = container.kind === 129 /* Constructor */; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 153 /* ArrowFunction */) { + while (container && container.kind === 157 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 191 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; + canUseSuperExpression = container.kind === 128 /* MethodDeclaration */ || container.kind === 127 /* MethodSignature */ || container.kind === 130 /* GetAccessor */ || container.kind === 131 /* SetAccessor */; } else { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */ || container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */; + canUseSuperExpression = container.kind === 128 /* MethodDeclaration */ || container.kind === 127 /* MethodSignature */ || container.kind === 130 /* GetAccessor */ || container.kind === 131 /* SetAccessor */ || container.kind === 126 /* PropertyDeclaration */ || container.kind === 125 /* PropertySignature */ || container.kind === 129 /* Constructor */; } } } @@ -13387,7 +14885,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 126 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 129 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -13406,9 +14904,9 @@ var ts; return unknownType; } function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (func.kind === 152 /* FunctionExpression */ || func.kind === 153 /* ArrowFunction */) { - if (isContextSensitiveExpression(func)) { + if (isFunctionExpressionOrArrowFunction(parameter.parent)) { + var func = parameter.parent; + if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var funcHasRestParameters = ts.hasRestParameters(func); @@ -13431,8 +14929,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 123 /* Parameter */) { - return getContextuallyTypedParameterType(declaration); + if (declaration.kind === 124 /* Parameter */) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); } } return undefined; @@ -13440,10 +14944,10 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { + if (func.type || func.kind === 129 /* Constructor */ || func.kind === 130 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 131 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } - var signature = getContextualSignature(func); + var signature = getContextualSignatureForFunctionLikeDeclaration(func); if (signature) { return getReturnTypeOfSignature(signature); } @@ -13462,12 +14966,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; - if (operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { + if (operator >= 52 /* FirstAssignment */ && operator <= 63 /* LastAssignment */) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 48 /* BarBarToken */) { + else if (operator === 49 /* BarBarToken */) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -13508,17 +15012,23 @@ var ts; function getIndexTypeOfContextualType(type, kind) { return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); } - function contextualTypeIsTupleType(type) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getPropertyOfObjectType(t, "0"); }) : getPropertyOfObjectType(type, "0")); + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return isTupleLikeType(t); }) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); } - function getContextualTypeForPropertyExpression(node) { - var declaration = node.parent; - var objectLiteral = declaration.parent; + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; var type = getContextualType(objectLiteral); - var name = declaration.name.text; + var name = element.name.text; if (type && name) { return getTypeOfPropertyOfContextualType(type, name) || isNumericName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || getIndexTypeOfContextualType(type, 0 /* String */); } @@ -13546,25 +15056,27 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: + case 189 /* VariableDeclaration */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 146 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 153 /* ArrowFunction */: - case 173 /* ReturnStatement */: + case 157 /* ArrowFunction */: + case 180 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return getContextualTypeForArgument(node); - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 143 /* PropertyAssignment */: - return getContextualTypeForPropertyExpression(node); - case 141 /* ArrayLiteral */: + case 204 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 147 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13578,8 +15090,15 @@ var ts; } } } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 156 /* FunctionExpression */ || node.kind === 157 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + } function getContextualSignature(node) { - var type = getContextualType(node); + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); if (!type) { return undefined; } @@ -13616,6 +15135,19 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper !== identityMapper; } + function isAssignmentTarget(node) { + var parent = node.parent; + if (parent.kind === 163 /* BinaryExpression */ && parent.operator === 52 /* EqualsToken */ && parent.left === node) { + return true; + } + if (parent.kind === 204 /* PropertyAssignment */) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 147 /* ArrayLiteralExpression */) { + return isAssignmentTarget(parent); + } + return false; + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; if (!elements.length) { @@ -13623,7 +15155,7 @@ var ts; } var elementTypes = ts.map(elements, function (e) { return checkExpression(e, contextualMapper); }); var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleType(contextualType)) { + if ((contextualType && contextualTypeIsTupleLikeType(contextualType)) || isAssignmentTarget(node)) { return createTupleType(elementTypes); } return createArrayType(getUnionType(elementTypes)); @@ -13635,34 +15167,39 @@ var ts; var members = node.symbol.members; var properties = {}; var contextualType = getContextualType(node); + var typeFlags; for (var id in members) { if (ts.hasProperty(members, id)) { var member = members[id]; - if (member.flags & 4 /* Property */) { + if (member.flags & 4 /* Property */ || ts.isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; - var type; - if (memberDecl.kind === 143 /* PropertyAssignment */) { - type = checkExpression(memberDecl.initializer, contextualMapper); + if (memberDecl.kind === 204 /* PropertyAssignment */) { + var type = checkExpression(memberDecl.initializer, contextualMapper); + } + else if (memberDecl.kind === 128 /* MethodDeclaration */) { + var type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 144 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 205 /* ShorthandPropertyAssignment */); + var type = memberDecl.name.kind === 122 /* ComputedPropertyName */ ? unknownType : checkExpression(memberDecl.name, contextualMapper); } - var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); + typeFlags |= type.flags; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; - if (member.valueDeclaration) + if (member.valueDeclaration) { prop.valueDeclaration = member.valueDeclaration; + } prop.type = type; prop.target = member; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); + var getAccessor = ts.getDeclarationOfKind(member, 130 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); + var setAccessor = ts.getDeclarationOfKind(member, 131 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13672,7 +15209,9 @@ var ts; } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); - return createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); + result.flags |= (typeFlags & 131072 /* Unwidened */); + return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { var propTypes = []; @@ -13692,17 +15231,17 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 124 /* Property */; + return s.valueDeclaration ? s.valueDeclaration.kind : 126 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } - function checkClassPropertyAccess(node, type, prop) { + function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 191 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13711,7 +15250,7 @@ var ts; } return; } - if (node.left.kind === 89 /* SuperKeyword */) { + if (left.kind === 90 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13725,8 +15264,14 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); } } - function checkPropertyAccess(node) { - var type = checkExpression(node.left); + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpressionOrQualifiedName(left); if (type === unknownType) return type; if (type !== anyType) { @@ -13734,20 +15279,20 @@ var ts; if (apparentType === unknownType) { return unknownType; } - var prop = getPropertyOfType(apparentType, node.right.text); + var prop = getPropertyOfType(apparentType, right.text); if (!prop) { - if (node.right.text) { - error(node.right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(node.right), typeToString(type)); + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === 90 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 128 /* MethodDeclaration */) { + error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); } } return getTypeOfSymbol(prop); @@ -13755,16 +15300,17 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var type = checkExpression(node.left); + var left = node.kind === 149 /* PropertyAccessExpression */ ? node.expression : node.left; + var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + if (left.kind === 90 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 128 /* MethodDeclaration */) { return false; } else { var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); return diagnostics.length === diagnosticsCount; } } @@ -13772,19 +15318,22 @@ var ts; return true; } function checkIndexedAccess(node) { - var objectType = getApparentType(checkExpression(node.object)); - var indexType = checkExpression(node.index); - if (objectType === unknownType) + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { return unknownType; - if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { - error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); } - if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { - var name = node.index.text; - var prop = getPropertyOfType(objectType, name); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); + if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== 8 /* StringLiteral */) { + error(node.argumentExpression, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } + if (node.argumentExpression) { + if (node.argumentExpression.kind === 8 /* StringLiteral */ || node.argumentExpression.kind === 7 /* NumericLiteral */) { + var name = node.argumentExpression.text; + var prop = getPropertyOfType(objectType, name); + if (prop) { + getNodeLinks(node).resolvedSymbol = prop; + return getTypeOfSymbol(prop); + } } } if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { @@ -13798,7 +15347,7 @@ var ts; if (stringIndexType) { return stringIndexType; } - if (compilerOptions.noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } return anyType; @@ -13807,7 +15356,7 @@ var ts; return unknownType; } function resolveUntypedCall(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -13825,26 +15374,26 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 158 /* TemplateExpression */) { + if (tagExpression.template.kind === 165 /* TemplateExpression */) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = lastSpan.literal.kind === 120 /* Missing */ || ts.isUnterminatedTemplateEnd(lastSpan.literal); + callIsIncomplete = ts.getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 9 /* NoSubstitutionTemplateLiteral */); - callIsIncomplete = ts.isUnterminatedTemplateEnd(templateLiteral); + ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + callIsIncomplete = !!templateLiteral.isUnterminated; } } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 148 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 152 /* NewExpression */); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13887,12 +15436,12 @@ var ts; var context = createInferenceContext(typeParameters, false); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { + if (args[i].kind === 167 /* OmittedExpression */) { continue; } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); - if (i === 0 && args[i].parent.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 153 /* TaggedTemplateExpression */) { inferTypes(context, globalTemplateStringsArrayType, parameterType); continue; } @@ -13901,7 +15450,7 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { + if (args[i].kind === 167 /* OmittedExpression */) { continue; } if (excludeArgument[i] === false) { @@ -13939,15 +15488,15 @@ var ts; for (var i = 0; i < args.length; i++) { var arg = args[i]; var argType; - if (arg.kind === 161 /* OmittedExpression */) { + if (arg.kind === 167 /* OmittedExpression */) { continue; } var paramType = getTypeAtPosition(signature, i); - if (i === 0 && node.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && node.kind === 153 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { - argType = arg.kind === 7 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + argType = arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1); if (!isValidArgument) { @@ -13958,10 +15507,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 153 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 165 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13973,7 +15522,7 @@ var ts; return args; } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 149 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 153 /* TaggedTemplateExpression */; var typeArguments = isTaggedTemplate ? undefined : node.typeArguments; ts.forEach(typeArguments, checkSourceElement); var candidates = candidatesOutArray || []; @@ -13985,7 +15534,7 @@ var ts; var args = getEffectiveCallArguments(node); var excludeArgument; for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitiveExpression(args[i])) { + if (isContextSensitive(args[i])) { if (!excludeArgument) { excludeArgument = new Array(args.length); } @@ -14020,7 +15569,7 @@ var ts; var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, node.func || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { @@ -14121,14 +15670,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 89 /* SuperKeyword */) { - var superType = checkSuperExpression(node.func); + if (node.expression.kind === 90 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } - var funcType = checkExpression(node.func); + var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); if (apparentType === unknownType) { return resolveErrorCall(node); @@ -14153,7 +15702,7 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function resolveNewExpression(node, candidatesOutArray) { - var expressionType = checkExpression(node.func); + var expressionType = checkExpression(node.expression); if (expressionType === anyType) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -14199,13 +15748,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 147 /* CallExpression */) { + if (node.kind === 151 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 148 /* NewExpression */) { + else if (node.kind === 152 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 153 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14216,12 +15765,12 @@ var ts; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 90 /* SuperKeyword */) { return voidType; } - if (node.kind === 148 /* NewExpression */) { + if (node.kind === 152 /* NewExpression */) { var declaration = signature.declaration; - if (declaration && declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */ && declaration.kind !== 134 /* ConstructorType */) { + if (declaration && declaration.kind !== 129 /* Constructor */ && declaration.kind !== 133 /* ConstructSignature */ && declaration.kind !== 137 /* ConstructorType */) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -14234,10 +15783,10 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkTypeAssertion(node) { - var exprType = checkExpression(node.operand); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (fullTypeCheck && targetType !== unknownType) { - var widenedType = getWidenedType(exprType, true); + var widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -14261,42 +15810,32 @@ var ts; } } function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 187 /* FunctionBlock */) { - var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); - var widenedType = getWidenedType(unwidenedType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType)); - } - return widenedType; + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (func.body.kind !== 169 /* Block */) { + var type = checkExpressionCached(func.body, contextualMapper); } - var types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); - if (types.length > 0) { - var commonType = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!commonType) { + else { + var types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + if (types.length === 0) { + return voidType; + } + var type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); return unknownType; } - var widenedType = getWidenedType(commonType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - var typeName = typeToString(widenedType); - if (func.name) { - error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(func.name), typeName); - } - else { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } - return widenedType; } - return voidType; + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + return getWidenedType(type); } function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkAndMarkExpression(expr, contextualMapper); + var type = checkExpressionCached(expr, contextualMapper); if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -14310,7 +15849,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 184 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -14319,7 +15858,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 187 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 169 /* Block */) { return; } var bodyBlock = func.body; @@ -14331,7 +15870,8 @@ var ts; } error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } - function checkFunctionExpression(node, contextualMapper) { + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (contextualMapper === identityMapper) { return anyFunctionType; } @@ -14343,7 +15883,7 @@ var ts; links.flags |= 64 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitiveExpression(node)) { + if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } if (!node.type) { @@ -14357,21 +15897,28 @@ var ts; checkSignatureDeclaration(node); } } + if (fullTypeCheck && node.kind !== 128 /* MethodDeclaration */ && node.kind !== 127 /* MethodSignature */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } return type; } - function checkFunctionExpressionBody(node) { + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 128 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 187 /* FunctionBlock */) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (node.body) { + if (node.body.kind === 169 /* Block */) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (node.type) { + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + } + checkFunctionExpressionBodies(node.body); } - checkFunctionExpressionBodies(node.body); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -14388,15 +15935,15 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - case 145 /* PropertyAccess */: + case 149 /* PropertyAccessExpression */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 146 /* IndexedAccess */: + case 150 /* ElementAccessExpression */: return true; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14404,20 +15951,20 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 149 /* PropertyAccessExpression */: var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 146 /* IndexedAccess */: - var index = n.index; - var symbol = findSymbol(n.object); - if (symbol && index.kind === 7 /* StringLiteral */) { + case 150 /* ElementAccessExpression */: + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 8 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -14433,22 +15980,29 @@ var ts; } return true; } - function checkPrefixExpression(node) { + function checkDeleteExpression(node) { + var operandType = checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + var operandType = checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + var operandType = checkExpression(node.expression); + return undefinedType; + } + function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: return numberType; - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: + case 46 /* ExclamationToken */: return booleanType; - case 95 /* TypeOfKeyword */: - return stringType; - case 97 /* VoidKeyword */: - return undefinedType; - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -14457,7 +16011,7 @@ var ts; } return unknownType; } - function checkPostfixExpression(node) { + function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -14469,7 +16023,7 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & 65025 /* Structured */) !== 0; + return (type.flags & (48128 /* ObjectType */ | 512 /* TypeParameter */)) !== 0; } function isConstEnumObjectType(type) { return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); @@ -14478,10 +16032,10 @@ var ts; return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (leftType !== unknownType && !isStructuredType(leftType)) { + if (!(leftType.flags & 1 /* Any */ || isStructuredType(leftType))) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (!(rightType.flags & 1 /* Any */ || isTypeSubtypeOf(rightType, globalFunctionType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -14490,36 +16044,97 @@ var ts; if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); } - if (!isStructuredType(rightType)) { + if (!(rightType.flags & 1 /* Any */ || isStructuredType(rightType))) { error(node.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, contextualMapper) { + var properties = node.properties; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 204 /* PropertyAssignment */ || p.kind === 205 /* ShorthandPropertyAssignment */) { + var name = p.name; + var type = sourceType.flags & 1 /* Any */ ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || isNumericName(name.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); + if (type) { + checkDestructuringAssignment(p.initializer || name, type); + } + else { + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + if (!isTypeAssignableTo(sourceType, anyArrayType)) { + error(node, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(sourceType)); + return sourceType; + } + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 167 /* OmittedExpression */) { + var propName = "" + i; + var type = sourceType.flags & 1 /* Any */ ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : getIndexTypeOfType(sourceType, 1 /* Number */); + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + return sourceType; + } + function checkDestructuringAssignment(target, sourceType, contextualMapper) { + if (target.kind === 163 /* BinaryExpression */ && target.operator === 52 /* EqualsToken */) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 148 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 147 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, undefined); + } + return sourceType; + } function checkBinaryExpression(node, contextualMapper) { var operator = node.operator; + if (operator === 52 /* EqualsToken */ && (node.left.kind === 148 /* ObjectLiteralExpression */ || node.left.kind === 147 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 34 /* AsteriskToken */: - case 54 /* AsteriskEqualsToken */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 36 /* PercentToken */: - case 56 /* PercentEqualsToken */: - case 33 /* MinusToken */: - case 53 /* MinusEqualsToken */: - case 39 /* LessThanLessThanToken */: - case 57 /* LessThanLessThanEqualsToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 58 /* GreaterThanGreaterThanEqualsToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: + case 35 /* AsteriskToken */: + case 55 /* AsteriskEqualsToken */: + case 36 /* SlashToken */: + case 56 /* SlashEqualsToken */: + case 37 /* PercentToken */: + case 57 /* PercentEqualsToken */: + case 34 /* MinusToken */: + case 54 /* MinusEqualsToken */: + case 40 /* LessThanLessThanToken */: + case 58 /* LessThanLessThanEqualsToken */: + case 41 /* GreaterThanGreaterThanToken */: + case 59 /* GreaterThanGreaterThanEqualsToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* BarToken */: + case 62 /* BarEqualsToken */: + case 45 /* CaretToken */: + case 63 /* CaretEqualsToken */: + case 43 /* AmpersandToken */: + case 61 /* AmpersandEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -14536,8 +16151,8 @@ var ts; } } return numberType; - case 32 /* PlusToken */: - case 52 /* PlusEqualsToken */: + case 33 /* PlusToken */: + case 53 /* PlusEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -14556,53 +16171,53 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 52 /* PlusEqualsToken */) { + if (operator === 53 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: + case 28 /* EqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: + case 24 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 26 /* LessThanEqualsToken */: + case 27 /* GreaterThanEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 85 /* InstanceOfKeyword */: + case 86 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 84 /* InKeyword */: + case 85 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 47 /* AmpersandAmpersandToken */: + case 48 /* AmpersandAmpersandToken */: return rightType; - case 48 /* BarBarToken */: + case 49 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 51 /* EqualsToken */: + case 52 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; - case 22 /* CommaToken */: + case 23 /* CommaToken */: return rightType; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - return 48 /* BarBarToken */; - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - return 30 /* ExclamationEqualsEqualsToken */; - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: - return 47 /* AmpersandAmpersandToken */; + case 44 /* BarToken */: + case 62 /* BarEqualsToken */: + return 49 /* BarBarToken */; + case 45 /* CaretToken */: + case 63 /* CaretEqualsToken */: + return 31 /* ExclamationEqualsEqualsToken */; + case 43 /* AmpersandToken */: + case 61 /* AmpersandEqualsToken */: + return 48 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (fullTypeCheck && operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { + if (fullTypeCheck && operator >= 52 /* FirstAssignment */ && operator <= 63 /* LastAssignment */) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14632,13 +16247,18 @@ var ts; node.contextualType = saveContextualType; return result; } - function checkAndMarkExpression(node, contextualMapper) { - var result = checkExpression(node, contextualMapper); - getNodeLinks(node).flags |= 1 /* TypeChecked */; - return result; + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; } - function checkExpression(node, contextualMapper) { - var type = checkExpressionNode(node, contextualMapper); + function checkObjectLiteralMethod(node, contextualMapper) { + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { if (contextualMapper && contextualMapper !== identityMapper) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { @@ -14646,72 +16266,90 @@ var ts; if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); } } } } + return type; + } + function checkExpression(node, contextualMapper) { + return checkExpressionOrQualifiedName(node, contextualMapper); + } + function checkExpressionOrQualifiedName(node, contextualMapper) { + var type; + if (node.kind == 121 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 145 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 146 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 149 /* PropertyAccessExpression */ && node.parent.expression === node) || (node.parent.kind === 150 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 64 /* Identifier */ || node.kind === 121 /* 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 checkExpressionNode(node, contextualMapper) { + function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: return checkIdentifier(node); - case 91 /* ThisKeyword */: + case 92 /* ThisKeyword */: return checkThisExpression(node); - case 89 /* SuperKeyword */: + case 90 /* SuperKeyword */: return checkSuperExpression(node); - case 87 /* NullKeyword */: + case 88 /* NullKeyword */: return nullType; - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: + case 94 /* TrueKeyword */: + case 79 /* FalseKeyword */: return booleanType; - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: return numberType; - case 158 /* TemplateExpression */: + case 165 /* TemplateExpression */: return checkTemplateExpression(node); - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: + case 8 /* StringLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: return stringType; - case 8 /* RegularExpressionLiteral */: + case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 121 /* QualifiedName */: - return checkPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 147 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 142 /* ObjectLiteral */: + case 148 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 145 /* PropertyAccess */: - return checkPropertyAccess(node); - case 146 /* IndexedAccess */: + case 149 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 150 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return checkCallExpression(node); - case 149 /* TaggedTemplateExpression */: + case 153 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return checkExpression(node.expression); - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return checkFunctionExpression(node, contextualMapper); - case 154 /* PrefixOperator */: - return checkPrefixExpression(node); - case 155 /* PostfixOperator */: - return checkPostfixExpression(node); - case 156 /* BinaryExpression */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 159 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 158 /* DeleteExpression */: + return checkDeleteExpression(node); + case 160 /* VoidExpression */: + return checkVoidExpression(node); + case 161 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 162 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 163 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 157 /* ConditionalExpression */: + case 164 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 161 /* OmittedExpression */: + case 167 /* OmittedExpression */: return undefinedType; } return unknownType; @@ -14723,47 +16361,19 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } - function checkParameter(parameterDeclaration) { - checkVariableDeclaration(parameterDeclaration); - if (fullTypeCheck) { - checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - if (parameterDeclaration.flags & 8 /* Rest */) { - if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) { - error(parameterDeclaration, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - else { - if (parameterDeclaration.initializer && !parameterDeclaration.parent.body) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - } + function checkParameter(node) { + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */)) { + func = ts.getContainingFunction(node); + if (!(func.kind === 129 /* Constructor */ && func.body)) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } - function checkReferencesInInitializer(n) { - if (n.kind === 63 /* Identifier */) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 123 /* Parameter */) { - if (referencedSymbol.valueDeclaration === parameterDeclaration) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(parameterDeclaration.name)); - return; - } - var enclosingOrReferencedParameter = ts.forEach(parameterDeclaration.parent.parameters, function (p) { return p === parameterDeclaration || p === referencedSymbol.valueDeclaration ? p : undefined; }); - if (enclosingOrReferencedParameter === referencedSymbol.valueDeclaration) { - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(parameterDeclaration.name), ts.declarationNameToString(n)); - } + if (node.dotDotDotToken) { + if (!isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } - else { - ts.forEachChild(n, checkReferencesInInitializer); - } - } - if (parameterDeclaration.initializer) { - checkReferencesInInitializer(parameterDeclaration.initializer); } } function checkSignatureDeclaration(node) { @@ -14773,16 +16383,13 @@ var ts; checkSourceElement(node.type); } if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 129 /* CallSignature */: + case 132 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14791,7 +16398,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 192 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14803,9 +16410,9 @@ var ts; var seenStringIndexer = false; for (var i = 0, len = indexSymbol.declarations.length; i < len; ++i) { var declaration = indexSymbol.declarations[i]; - if (declaration.parameters.length == 1 && declaration.parameters[0].type) { + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 118 /* StringKeyword */: + case 119 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14813,7 +16420,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 116 /* NumberKeyword */: + case 117 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14827,16 +16434,16 @@ var ts; } } function checkPropertyDeclaration(node) { - checkVariableDeclaration(node); + checkVariableLikeDeclaration(node); } function checkMethodDeclaration(node) { - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(symbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(symbol); } @@ -14847,37 +16454,37 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 147 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; + return n.kind === 151 /* CallExpression */ && n.expression.kind === 90 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 142 /* ObjectLiteral */: return false; + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + case 148 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 91 /* ThisKeyword */) { + if (n.kind === 92 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) { + else if (n.kind !== 156 /* FunctionExpression */ && n.kind !== 190 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; + return n.kind === 126 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } - if (node.parent.baseType) { + if (ts.getClassBaseTypeNode(node.parent)) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 172 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14892,28 +16499,30 @@ var ts; } function checkAccessorDeclaration(node) { if (fullTypeCheck) { - if (node.kind === 127 /* GetAccessor */) { + if (node.kind === 130 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; - var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + if (!ts.hasComputedNameButNotSymbol(node)) { + var otherKind = node.kind === 130 /* GetAccessor */ ? 131 /* SetAccessor */ : 130 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } } } + checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); } } - checkFunctionDeclaration(node); - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + checkFunctionLikeDeclaration(node); } function checkTypeReference(node) { var type = getTypeFromTypeReferenceNode(node); @@ -14965,9 +16574,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 192 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 132 /* CallSignature */ || signatureDeclarationNode.kind === 133 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 132 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14985,7 +16594,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 192 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -14997,11 +16606,14 @@ var ts; if (!fullTypeCheck) { return; } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - var canonicalFlags = implementationSharesContainerWithFirstOverload ? getEffectiveDeclarationFlags(implementation, flagsToCheck) : getEffectiveDeclarationFlags(overloads[0], flagsToCheck); + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & 1 /* Export */) { @@ -15013,15 +16625,25 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 4 /* QuestionMark */) { + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 4 /* QuestionMark */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; var hasOverloads = false; var bodyDeclaration; var lastSeenNonAmbientDeclaration; @@ -15029,7 +16651,7 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 120 /* Missing */) { + if (node.name && ts.getFullWidth(node.name) === 0) { return; } var seen = false; @@ -15045,7 +16667,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 125 /* Method */); + ts.Debug.assert(node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); @@ -15071,14 +16693,16 @@ var ts; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 192 /* InterfaceDeclaration */ || node.parent.kind === 139 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { + if (node.kind === 190 /* FunctionDeclaration */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 129 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); if (node.body && bodyDeclaration) { if (isConstructor) { multipleConstructorImplementation = true; @@ -15119,6 +16743,7 @@ var ts; } if (hasOverloads) { checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -15141,11 +16766,11 @@ var ts; var symbol = node.localSymbol; if (!symbol) { symbol = getSymbolOfNode(node); - if (!(symbol.flags & 29360128 /* Export */)) { + if (!(symbol.flags & 7340032 /* Export */)) { return; } } - if (getDeclarationOfKind(symbol, node.kind) !== node) { + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } var exportedDeclarationSpaces = 0; @@ -15169,14 +16794,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 189 /* InterfaceDeclaration */: - return 8388608 /* ExportType */; - case 192 /* ModuleDeclaration */: - return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - return 8388608 /* ExportType */ | 4194304 /* ExportValue */; - case 194 /* ImportDeclaration */: + case 192 /* InterfaceDeclaration */: + return 2097152 /* ExportType */; + case 195 /* ModuleDeclaration */: + return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + return 2097152 /* ExportType */ | 1048576 /* ExportValue */; + case 197 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -15184,113 +16809,83 @@ var ts; }); return result; default: - return 4194304 /* ExportValue */; + return 1048576 /* ExportValue */; } } } function checkFunctionDeclaration(node) { - checkSignatureDeclaration(node); - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); + checkFunctionLikeDeclaration(node); + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } - if (symbol.parent) { - if (getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); + } + function checkFunctionLikeDeclaration(node) { + checkSignatureDeclaration(node); + if (!ts.hasComputedNameButNotSymbol(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } } } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind)) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) { - if (!isPrivateWithinAmbient(node)) { - var typeName = typeToString(anyType); - if (node.name) { - error(node, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(node.name), typeName); - } - else { - error(node, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } + if (compilerOptions.noImplicitAny && !node.body && !node.type && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); } } function checkBlock(node) { ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 196 /* ModuleBlock */) { + checkFunctionExpressionBodies(node); + } } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) { return; } ts.forEach(node.parameters, function (p) { - if (p.name && p.name.text === argumentsSymbol.name) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); } }); } - function checkCollisionWithIndexVariableInGeneratedCode(node, name) { - if (!(name && name.text === "_i")) { - return; - } - if (node.kind === 123 /* Parameter */) { - if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) { - error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); - } - return; - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol === unknownSymbol) { - return; - } - var current = node; - while (current) { - var definedOnCurrentLevel = ts.forEach(symbol.declarations, function (d) { return d.parent === current ? d : undefined; }); - if (definedOnCurrentLevel) { - return; - } - switch (current.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - if (ts.hasRestParameters(current)) { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); - return; - } - break; - } - current = current.parent; - } - } function needCollisionCheckForIdentifier(node, identifier, name) { if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { + if (node.kind === 126 /* PropertyDeclaration */ || node.kind === 125 /* PropertySignature */ || node.kind === 128 /* MethodDeclaration */ || node.kind === 127 /* MethodSignature */ || node.kind === 130 /* GetAccessor */ || node.kind === 131 /* SetAccessor */) { return false; } if (ts.isInAmbientContext(node)) { return false; } - if (node.kind === 123 /* Parameter */ && !node.parent.body) { + var root = getRootDeclaration(node); + if (root.kind === 124 /* Parameter */ && !root.parent.body) { return false; } return true; } function checkCollisionWithCapturedThisVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); } - potentialThisCollisions.push(node); } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration = node.kind !== 63 /* Identifier */; + var isDeclaration = node.kind !== 64 /* Identifier */; if (isDeclaration) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -15306,12 +16901,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 191 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } - if (enclosingClass.baseType) { - var isDeclaration = node.kind !== 63 /* Identifier */; + if (ts.getClassBaseTypeNode(enclosingClass)) { + var isDeclaration = node.kind !== 64 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -15324,11 +16919,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 195 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = getDeclarationContainer(node); + if (parent.kind === 207 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -15345,38 +16940,87 @@ var ts; } } } - function checkVariableDeclaration(node) { - checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); - if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - var type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; + function isParameterDeclaration(node) { + while (node.kind === 146 /* BindingElement */) { + node = node.parent.parent; + } + return node.kind === 124 /* Parameter */; + } + function checkParameterInitializer(node) { + if (getRootDeclaration(node).kind === 124 /* Parameter */) { + var func = ts.getContainingFunction(node); + visit(node.initializer); + } + function visit(n) { + if (n.kind === 64 /* Identifier */) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 124 /* Parameter */) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } } else { - type = getTypeOfVariableOrPropertyDeclaration(node); - } - if (node.initializer) { - if (!(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); - } - checkCollisionWithConstDeclarations(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - if (!useTypeFromValueDeclaration) { - if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { - error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); - } + ts.forEachChild(n, visit); } } } + function checkVariableLikeDeclaration(node) { + checkSourceElement(node.type); + if (ts.hasComputedNameButNotSymbol(node)) { + if (node.initializer) { + checkExpressionCached(node.initializer); + } + return; + } + if (ts.isBindingPattern(node.name)) { + ts.forEach(node.name.elements, checkSourceElement); + } + if (node.initializer && getRootDeclaration(node).kind === 124 /* Parameter */ && !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) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkParameterInitializer(node); + } + } + else { + var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { + error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + } + } + if (node.kind !== 126 /* PropertyDeclaration */ && node.kind !== 125 /* PropertySignature */) { + checkExportsOnMergedDeclarations(node); + checkCollisionWithConstDeclarations(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } function checkVariableStatement(node) { - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkSourceElement); } function checkExpressionStatement(node) { checkExpression(node.expression); @@ -15396,7 +17040,7 @@ var ts; } function checkForStatement(node) { if (node.declarations) - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableLikeDeclaration); if (node.initializer) checkExpression(node.initializer); if (node.condition) @@ -15409,7 +17053,7 @@ var ts; if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; - checkVariableDeclaration(decl); + checkVariableLikeDeclaration(decl); if (decl.type) { error(decl, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); } @@ -15425,33 +17069,34 @@ var ts; } } var exprType = checkExpression(node.expression); - if (!isStructuredType(exprType) && exprType !== unknownType) { + if (!(exprType.flags & 1 /* Any */ || isStructuredType(exprType))) { 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); } function checkBreakOrContinueStatement(node) { } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 130 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 131 /* SetAccessor */))); + } function checkReturnStatement(node) { - if (node.expression && !(getNodeLinks(node.expression).flags & 1 /* TypeChecked */)) { + if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - if (func.kind === 128 /* SetAccessor */) { - if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var exprType = checkExpressionCached(node.expression); + if (func.kind === 131 /* SetAccessor */) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); - if (checkAssignability) { - checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); - } - else if (func.kind == 126 /* Constructor */) { - if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) { + if (func.kind === 129 /* Constructor */) { + if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + } } } } @@ -15463,25 +17108,28 @@ var ts; function checkSwitchStatement(node) { var expressionType = checkExpression(node.expression); ts.forEach(node.clauses, function (clause) { - if (fullTypeCheck && clause.expression) { - var caseType = checkExpression(clause.expression); + if (fullTypeCheck && clause.kind === 200 /* CaseClause */) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, clause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); } } - checkBlock(clause); + ts.forEach(clause.statements, checkSourceElement); }); } function checkLabeledStatement(node) { checkSourceElement(node.statement); } function checkThrowStatement(node) { - checkExpression(node.expression); + if (node.expression) { + checkExpression(node.expression); + } } function checkTryStatement(node) { checkBlock(node.tryBlock); - if (node.catchBlock) - checkBlock(node.catchBlock); + if (node.catchClause) + checkBlock(node.catchClause.block); if (node.finallyBlock) checkBlock(node.finallyBlock); } @@ -15566,9 +17214,10 @@ var ts; var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); var staticType = getTypeOfSymbol(symbol); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkTypeReference(node.baseType); + checkTypeReference(baseTypeNode); } if (type.baseTypes.length) { if (fullTypeCheck) { @@ -15576,15 +17225,16 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { - error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, 107455 /* Value */)) { + error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); } - checkExpression(node.baseType.typeName); + checkExpressionOrQualifiedName(baseTypeNode.typeName); } - if (node.implementedTypes) { - ts.forEach(node.implementedTypes, function (typeRefNode) { + var implementedTypeNodes = ts.getClassImplementedTypeNodes(node); + if (implementedTypeNodes) { + ts.forEach(implementedTypeNodes, function (typeRefNode) { checkTypeReference(typeRefNode); if (fullTypeCheck) { var t = getTypeFromTypeReferenceNode(typeRefNode); @@ -15607,13 +17257,13 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 67108864 /* Instantiated */ ? getSymbolLinks(s).target : s; + return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); for (var i = 0, len = baseProperties.length; i < len; ++i) { var base = getTargetSymbol(baseProperties[i]); - if (base.flags & 536870912 /* Prototype */) { + if (base.flags & 134217728 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -15653,7 +17303,7 @@ var ts; } } function isAccessor(kind) { - return kind === 127 /* GetAccessor */ || kind === 128 /* SetAccessor */; + return kind === 130 /* GetAccessor */ || kind === 131 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15719,7 +17369,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 192 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15735,7 +17385,7 @@ var ts; } } } - ts.forEach(node.baseTypes, checkTypeReference); + ts.forEach(ts.getInterfaceBaseTypeNodes(node), checkTypeReference); ts.forEach(node.members, checkSourceElement); if (fullTypeCheck) { checkTypeForDuplicateIndexSignatures(node); @@ -15790,18 +17440,18 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 154 /* PrefixOperator */: + case 161 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 32 /* PlusToken */: return value; - case 33 /* MinusToken */: return -value; - case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; + case 33 /* PlusToken */: return value; + case 34 /* MinusToken */: return -value; + case 47 /* TildeToken */: return enumIsConst ? ~value : undefined; } return undefined; - case 156 /* BinaryExpression */: + case 163 /* BinaryExpression */: if (!enumIsConst) { return undefined; } @@ -15814,26 +17464,26 @@ var ts; return undefined; } switch (e.operator) { - case 43 /* BarToken */: return left | right; - case 42 /* AmpersandToken */: return left & right; - case 40 /* GreaterThanGreaterThanToken */: return left >> right; - case 41 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 39 /* LessThanLessThanToken */: return left << right; - case 44 /* CaretToken */: return left ^ right; - case 34 /* AsteriskToken */: return left * right; - case 35 /* SlashToken */: return left / right; - case 32 /* PlusToken */: return left + right; - case 33 /* MinusToken */: return left - right; - case 36 /* PercentToken */: return left % right; + case 44 /* BarToken */: return left | right; + case 43 /* AmpersandToken */: return left & right; + case 41 /* GreaterThanGreaterThanToken */: return left >> right; + case 42 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 40 /* LessThanLessThanToken */: return left << right; + case 45 /* CaretToken */: return left ^ right; + case 35 /* AsteriskToken */: return left * right; + case 36 /* SlashToken */: return left / right; + case 33 /* PlusToken */: return left + right; + case 34 /* MinusToken */: return left - right; + case 37 /* PercentToken */: return left % right; } return undefined; - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: return +e.text; - case 151 /* ParenExpression */: + case 155 /* ParenthesizedExpression */: return enumIsConst ? evalConstant(e.expression) : undefined; - case 63 /* Identifier */: - case 146 /* IndexedAccess */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 150 /* ElementAccessExpression */: + case 149 /* PropertyAccessExpression */: if (!enumIsConst) { return undefined; } @@ -15841,21 +17491,21 @@ var ts; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 63 /* Identifier */) { + if (e.kind === 64 /* Identifier */) { enumType = currentType; propertyName = e.text; } else { - if (e.kind === 146 /* IndexedAccess */) { - if (e.index.kind !== 7 /* StringLiteral */) { + if (e.kind === 150 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; } - var enumType = getTypeOfNode(e.object); - propertyName = e.index.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.argumentExpression.text; } else { - var enumType = getTypeOfNode(e.left); - propertyName = e.right.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.name.text; } if (enumType !== currentType) { return undefined; @@ -15890,7 +17540,7 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { var enumIsConst = ts.isConst(node); @@ -15902,7 +17552,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 191 /* EnumDeclaration */) { + if (declaration.kind !== 194 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -15925,7 +17575,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 191 /* ClassDeclaration */ || (declaration.kind === 190 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15948,7 +17598,7 @@ var ts; } } } - if (node.name.kind === 7 /* StringLiteral */) { + if (node.name.kind === 8 /* StringLiteral */) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); } @@ -15970,34 +17620,39 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; - if (node.entityName) { + if (ts.isInternalModuleImportDeclaration(node)) { target = resolveImport(symbol); if (target !== unknownSymbol) { if (target.flags & 107455 /* Value */) { - var moduleName = getFirstIdentifier(node.entityName); + var moduleName = getFirstIdentifier(node.moduleReference); if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { - checkExpression(node.entityName); + checkExpressionOrQualifiedName(node.moduleReference); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 3152352 /* Type */) { + if (target.flags & 793056 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (node.parent.kind === 197 /* SourceFile */) { + if (node.parent.kind === 207 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { - if (isExternalModuleNameRelative(node.externalModuleName.text)) { - error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); - target = unknownSymbol; + else if (node.parent.kind === 196 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */) { + if (ts.getExternalModuleImportDeclarationExpression(node).kind === 8 /* StringLiteral */) { + if (isExternalModuleNameRelative(ts.getExternalModuleImportDeclarationExpression(node).text)) { + error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + target = unknownSymbol; + } + else { + target = resolveImport(symbol); + } } else { - target = resolveImport(symbol); + target = unknownSymbol; } } else { @@ -16005,7 +17660,7 @@ var ts; } } if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 3152352 /* Type */ ? 3152352 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { error(node, ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0, symbolToString(symbol)); } @@ -16013,7 +17668,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 197 /* SourceFile */) { + if (container.kind !== 207 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -16022,170 +17677,180 @@ var ts; if (!node) return; switch (node.kind) { - case 122 /* TypeParameter */: + case 123 /* TypeParameter */: return checkTypeParameter(node); - case 123 /* Parameter */: + case 124 /* Parameter */: return checkParameter(node); - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return checkPropertyDeclaration(node); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: + case 136 /* FunctionType */: + case 137 /* ConstructorType */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: return checkSignatureDeclaration(node); - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: return checkMethodDeclaration(node); - case 126 /* Constructor */: + case 129 /* Constructor */: return checkConstructorDeclaration(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return checkAccessorDeclaration(node); - case 132 /* TypeReference */: + case 135 /* TypeReference */: return checkTypeReference(node); - case 135 /* TypeQuery */: + case 138 /* TypeQuery */: return checkTypeQuery(node); - case 136 /* TypeLiteral */: + case 139 /* TypeLiteral */: return checkTypeLiteral(node); - case 137 /* ArrayType */: + case 140 /* ArrayType */: return checkArrayType(node); - case 138 /* TupleType */: + case 141 /* TupleType */: return checkTupleType(node); - case 139 /* UnionType */: + case 142 /* UnionType */: return checkUnionType(node); - case 140 /* ParenType */: + case 143 /* ParenthesizedType */: return checkSourceElement(node.type); - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 162 /* Block */: + case 169 /* Block */: + case 196 /* ModuleBlock */: return checkBlock(node); - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - return checkBody(node); - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return checkVariableStatement(node); - case 165 /* ExpressionStatement */: + case 172 /* ExpressionStatement */: return checkExpressionStatement(node); - case 166 /* IfStatement */: + case 173 /* IfStatement */: return checkIfStatement(node); - case 167 /* DoStatement */: + case 174 /* DoStatement */: return checkDoStatement(node); - case 168 /* WhileStatement */: + case 175 /* WhileStatement */: return checkWhileStatement(node); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return checkForStatement(node); - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return checkForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return checkReturnStatement(node); - case 174 /* WithStatement */: + case 181 /* WithStatement */: return checkWithStatement(node); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return checkSwitchStatement(node); - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return checkLabeledStatement(node); - case 179 /* ThrowStatement */: + case 184 /* ThrowStatement */: return checkThrowStatement(node); - case 180 /* TryStatement */: + case 185 /* TryStatement */: return checkTryStatement(node); - case 185 /* VariableDeclaration */: - return ts.Debug.fail("Checker encountered variable declaration"); - case 188 /* ClassDeclaration */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + return checkVariableLikeDeclaration(node); + case 191 /* ClassDeclaration */: return checkClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 193 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return checkImportDeclaration(node); - case 195 /* ExportAssignment */: + case 198 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); - checkFunctionExpressionBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + ts.forEach(node.parameters, checkFunctionExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 174 /* WithStatement */: + case 181 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 123 /* Parameter */: - case 124 /* Property */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 143 /* PropertyAssignment */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 197 /* SourceFile */: + case 124 /* Parameter */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + case 146 /* BindingElement */: + case 147 /* ArrayLiteralExpression */: + case 148 /* ObjectLiteralExpression */: + case 204 /* PropertyAssignment */: + case 149 /* PropertyAccessExpression */: + case 150 /* ElementAccessExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 153 /* TaggedTemplateExpression */: + case 154 /* TypeAssertionExpression */: + case 155 /* ParenthesizedExpression */: + case 159 /* TypeOfExpression */: + case 160 /* VoidExpression */: + case 158 /* DeleteExpression */: + case 161 /* PrefixUnaryExpression */: + case 162 /* PostfixUnaryExpression */: + case 163 /* BinaryExpression */: + case 164 /* ConditionalExpression */: + case 169 /* Block */: + case 196 /* ModuleBlock */: + case 170 /* VariableStatement */: + case 172 /* ExpressionStatement */: + case 173 /* IfStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 178 /* ContinueStatement */: + case 179 /* BreakStatement */: + case 180 /* ReturnStatement */: + case 182 /* SwitchStatement */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + case 183 /* LabeledStatement */: + case 184 /* ThrowStatement */: + case 185 /* TryStatement */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + case 189 /* VariableDeclaration */: + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 206 /* EnumMember */: + case 207 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } } - function checkBody(node) { - checkBlock(node); - checkFunctionExpressionBodies(node); - } function checkSourceFile(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { emitExtends = false; potentialThisCollisions.length = 0; - checkBody(node); + ts.forEach(node.statements, checkSourceElement); + checkFunctionExpressionBodies(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); - if (symbol && symbol.flags & 33554432 /* Import */) { + if (symbol && symbol.flags & 8388608 /* Import */) { getSymbolLinks(symbol).referenced = true; } } @@ -16193,14 +17858,12 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) + if (emitExtends) { links.flags |= 8 /* EmitExtends */; + } links.flags |= 1 /* TypeChecked */; } } - function checkProgram() { - ts.forEach(program.getSourceFiles(), checkSourceFile); - } function getSortedDiagnostics() { ts.Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode"); if (diagnosticsModified) { @@ -16215,7 +17878,7 @@ var ts; checkSourceFile(sourceFile); return ts.filter(getSortedDiagnostics(), function (d) { return d.file === sourceFile; }); } - checkProgram(); + ts.forEach(program.getSourceFiles(), checkSourceFile); return getSortedDiagnostics(); } function getDeclarationDiagnostics(targetSourceFile) { @@ -16226,25 +17889,10 @@ var ts; function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } - function getNodeAtPosition(sourceFile, position) { - function findChildAtPosition(parent) { - var child = ts.forEachChild(parent, function (node) { - if (position >= node.pos && position <= node.end && position >= ts.getTokenPosOfNode(node)) { - return findChildAtPosition(node); - } - }); - return child || parent; - } - if (position < sourceFile.pos) - position = sourceFile.pos; - if (position > sourceFile.end) - position = sourceFile.end; - return findChildAtPosition(sourceFile); - } function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 181 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -16280,28 +17928,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); + case 195 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); + copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 152 /* FunctionExpression */: + case 156 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 182 /* CatchBlock */: - if (location.variable.text) { + case 203 /* CatchClause */: + if (location.name.text) { copySymbol(location.symbol, meaning); } break; @@ -16313,15 +17961,15 @@ var ts; return ts.mapToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 63 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; + return name.kind == 64 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 122 /* TypeParameter */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: + case 123 /* TypeParameter */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 194 /* EnumDeclaration */: return true; } } @@ -16329,60 +17977,62 @@ var ts; var node = entityName; while (node.parent && node.parent.kind === 121 /* QualifiedName */) node = node.parent; - return node.parent && node.parent.kind === 132 /* TypeReference */; + return node.parent && node.parent.kind === 135 /* TypeReference */; } function isTypeNode(node) { - if (132 /* FirstTypeNode */ <= node.kind && node.kind <= 140 /* LastTypeNode */) { + if (135 /* FirstTypeNode */ <= node.kind && node.kind <= 143 /* LastTypeNode */) { return true; } switch (node.kind) { - case 109 /* AnyKeyword */: - case 116 /* NumberKeyword */: - case 118 /* StringKeyword */: - case 110 /* BooleanKeyword */: + case 110 /* AnyKeyword */: + case 117 /* NumberKeyword */: + case 119 /* StringKeyword */: + case 111 /* BooleanKeyword */: return true; - case 97 /* VoidKeyword */: - return node.parent.kind !== 154 /* PrefixOperator */; - case 7 /* StringLiteral */: - return node.parent.kind === 123 /* Parameter */; - case 63 /* Identifier */: + case 98 /* VoidKeyword */: + return node.parent.kind !== 160 /* VoidExpression */; + case 8 /* StringLiteral */: + return node.parent.kind === 124 /* Parameter */; + case 64 /* Identifier */: if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } case 121 /* QualifiedName */: - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + ts.Debug.assert(node.kind === 64 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; - if (parent.kind === 135 /* TypeQuery */) { + if (parent.kind === 138 /* TypeQuery */) { return false; } - if (132 /* FirstTypeNode */ <= parent.kind && parent.kind <= 140 /* LastTypeNode */) { + if (135 /* FirstTypeNode */ <= parent.kind && parent.kind <= 143 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 122 /* TypeParameter */: + case 123 /* TypeParameter */: return node === parent.constraint; - case 124 /* Property */: - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: return node === parent.type; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 129 /* Constructor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: return node === parent.type; - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: return node === parent.type; - case 150 /* TypeAssertion */: + case 154 /* TypeAssertionExpression */: return node === parent.type; - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; - case 149 /* TaggedTemplateExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 153 /* TaggedTemplateExpression */: return false; } } @@ -16392,49 +18042,58 @@ var ts; while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 194 /* ImportDeclaration */) { - return node.parent.entityName === node; + if (node.parent.kind === 197 /* ImportDeclaration */) { + return node.parent.moduleReference === node; } - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 198 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 145 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) || (node.parent.kind === 149 /* PropertyAccessExpression */ && node.parent.name === node); } - function getSymbolOfEntityName(entityName) { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 195 /* ExportAssignment */) { - return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); + if (entityName.parent.kind === 198 /* ExportAssignment */) { + return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Import */); } - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImport(entityName); + if (entityName.kind !== 149 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImport(entityName); + } } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (ts.isExpression(entityName)) { - if (entityName.kind === 63 /* Identifier */) { - var meaning = 107455 /* Value */ | 33554432 /* Import */; + if (ts.getFullWidth(entityName) === 0) { + return undefined; + } + if (entityName.kind === 64 /* Identifier */) { + var meaning = 107455 /* Value */ | 8388608 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 145 /* PropertyAccess */) { + else if (entityName.kind === 149 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { - checkPropertyAccess(entityName); + checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else { - return; + else if (entityName.kind === 121 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 132 /* TypeReference */ ? 3152352 /* Type */ : 1536 /* Namespace */; - meaning |= 33554432 /* Import */; + var meaning = entityName.parent.kind === 135 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + meaning |= 8388608 /* Import */; return resolveEntityName(entityName, entityName, meaning); } return undefined; @@ -16446,33 +18105,33 @@ var ts; if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + if (node.kind === 64 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 198 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { - case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 149 /* PropertyAccessExpression */: case 121 /* QualifiedName */: - return getSymbolOfEntityName(node); - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 111 /* ConstructorKeyword */: + case 112 /* ConstructorKeyword */: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 126 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 129 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 7 /* StringLiteral */: - if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) { - var importSymbol = getSymbolOfNode(node.parent); + case 8 /* StringLiteral */: + if (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node) { + var importSymbol = getSymbolOfNode(node.parent.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } - case 6 /* NumericLiteral */: - if (node.parent.kind == 146 /* IndexedAccess */ && node.parent.index === node) { - var objectType = checkExpression(node.parent.object); + case 7 /* NumericLiteral */: + if (node.parent.kind == 150 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); @@ -16485,7 +18144,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 144 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 205 /* ShorthandPropertyAssignment */) { return resolveEntityName(location, location.name, 107455 /* Value */); } return undefined; @@ -16542,7 +18201,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 1073741824 /* UnionProperty */) { + if (symbol.flags & 268435456 /* UnionProperty */) { var symbols = []; var name = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { @@ -16550,7 +18209,7 @@ var ts; }); return symbols; } - else if (symbol.flags & 268435456 /* Transient */) { + else if (symbol.flags & 67108864 /* Transient */) { var target = getSymbolLinks(symbol).target; if (target) { return [target]; @@ -16559,7 +18218,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 207 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -16571,7 +18230,7 @@ var ts; } function isUniqueLocalName(name, container) { for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 4194304 /* ExportValue */)) { + if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */)) { return false; } } @@ -16592,7 +18251,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 195 /* ModuleDeclaration */ || node.kind === 194 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -16616,13 +18275,13 @@ var ts; return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } function isTopLevelValueImportWithEntityName(node) { - if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) { + if (node.parent.kind !== 207 /* SourceFile */ || !ts.isInternalModuleImportDeclaration(node)) { return false; } return isImportResolvedToValue(getSymbolOfNode(node)); } - function hasSemanticErrors() { - return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; + function hasSemanticErrors(sourceFile) { + return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0; } function isEmitBlocked(sourceFile) { return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); @@ -16667,21 +18326,24 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 206 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } return undefined; } - function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getTypeOfSymbol(symbol) : unknownType; getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { var signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } + function isUnknownIdentifier(location, name) { + return !resolveName(location, name, 107455 /* Value */, undefined, undefined); + } function createResolver() { return { getProgram: function () { return program; }, @@ -16696,16 +18358,16 @@ var ts; isEmitBlocked: isEmitBlocked, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, - writeTypeAtLocation: writeTypeAtLocation, + writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue + getConstantValue: getConstantValue, + isUnknownIdentifier: isUnknownIdentifier }; } function invokeEmitter(targetSourceFile) { var resolver = createResolver(); - checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } function initializeTypeChecker() { @@ -16731,6 +18393,7 @@ var ts; globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTemplateStringsArrayType = compilerOptions.target >= 2 /* ES6 */ ? getGlobalType("TemplateStringsArray") : unknownType; + anyArrayType = createArrayType(anyType); } initializeTypeChecker(); return checker; @@ -16738,123 +18401,6 @@ var ts; ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); var ts; -(function (ts) { - var TextSpan = (function () { - function TextSpan(start, length) { - ts.Debug.assert(start >= 0, "start"); - ts.Debug.assert(length >= 0, "length"); - this._start = start; - this._length = length; - } - TextSpan.prototype.toJSON = function (key) { - return { start: this._start, length: this._length }; - }; - TextSpan.prototype.start = function () { - return this._start; - }; - TextSpan.prototype.length = function () { - return this._length; - }; - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = Math.max(this._start, span._start); - var overlapEnd = Math.min(this.end(), span.end()); - return overlapStart < overlapEnd; - }; - TextSpan.prototype.overlap = function (span) { - var overlapStart = Math.max(this._start, span._start); - var overlapEnd = Math.min(this.end(), span.end()); - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - return undefined; - }; - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - TextSpan.prototype.intersection = function (span) { - var intersectStart = Math.max(this._start, span._start); - var intersectEnd = Math.min(this.end(), span.end()); - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - return undefined; - }; - TextSpan.fromBounds = function (start, end) { - ts.Debug.assert(start >= 0); - ts.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - ts.TextSpan = TextSpan; - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - ts.Debug.assert(newLength >= 0, "newLength"); - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - TextChangeRange.prototype.newSpan = function () { - return new TextSpan(this.span().start(), this.newLength()); - }; - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return new TextChangeRange(TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TextSpan(0, 0), 0); - return TextChangeRange; - })(); - ts.TextChangeRange = TextChangeRange; -})(ts || (ts = {})); -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -16874,10 +18420,10 @@ var ts; } function autoCollapse(node) { switch (node.kind) { - case 193 /* ModuleBlock */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 196 /* ModuleBlock */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: return false; } return true; @@ -16889,44 +18435,44 @@ var ts; return; } switch (n.kind) { - case 162 /* Block */: - var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); - if (parent.kind === 167 /* DoStatement */ || parent.kind === 170 /* ForInStatement */ || parent.kind === 169 /* ForStatement */ || parent.kind === 166 /* IfStatement */ || parent.kind === 168 /* WhileStatement */ || parent.kind === 174 /* WithStatement */) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + case 169 /* Block */: + if (!ts.isFunctionBlock(n)) { + var parent = n.parent; + var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + if (parent.kind === 174 /* DoStatement */ || parent.kind === 177 /* ForInStatement */ || parent.kind === 176 /* ForStatement */ || parent.kind === 173 /* IfStatement */ || parent.kind === 175 /* WhileStatement */ || parent.kind === 181 /* WithStatement */ || parent.kind === 203 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + } + else { + var span = ts.TextSpan.fromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + } + break; } - else { - var span = ts.TextSpan.fromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span, - hintSpan: span, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - } - break; - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); + case 196 /* ModuleBlock */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 142 /* ObjectLiteral */: - case 175 /* SwitchStatement */: - var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 148 /* ObjectLiteralExpression */: + case 182 /* SwitchStatement */: + var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; - case 141 /* ArrayLiteral */: - var openBracket = ts.findChildOfKind(n, 17 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 18 /* CloseBracketToken */, sourceFile); + case 147 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -16952,14 +18498,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: do { current = current.parent; - } while (current.kind === 192 /* ModuleDeclaration */); - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 186 /* FunctionDeclaration */: + } while (current.kind === 195 /* ModuleDeclaration */); + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 192 /* InterfaceDeclaration */: + case 190 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -16968,15 +18514,29 @@ var ts; } function getChildNodes(nodes) { var childNodes = []; - for (var i = 0, n = nodes.length; i < n; i++) { - var node = nodes[i]; - if (node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */ || node.kind === 189 /* InterfaceDeclaration */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 186 /* FunctionDeclaration */) { - childNodes.push(node); - } - else if (node.kind === 163 /* VariableStatement */) { - childNodes.push.apply(childNodes, node.declarations); + function visit(node) { + switch (node.kind) { + case 170 /* VariableStatement */: + ts.forEach(node.declarations, visit); + break; + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + ts.forEach(node.elements, visit); + break; + case 189 /* VariableDeclaration */: + if (ts.isBindingPattern(node)) { + visit(node.name); + break; + } + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 192 /* InterfaceDeclaration */: + case 195 /* ModuleDeclaration */: + case 190 /* FunctionDeclaration */: + childNodes.push(node); } } + ts.forEach(nodes, visit); return sortNodes(childNodes); } function getTopLevelNodes(node) { @@ -17006,17 +18566,17 @@ var ts; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; switch (node.kind) { - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 192 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -17027,12 +18587,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 186 /* FunctionDeclaration */) { - if (functionDeclaration.body && functionDeclaration.body.kind === 187 /* FunctionBlock */) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 186 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 190 /* FunctionDeclaration */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 169 /* Block */) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 190 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } - if (functionDeclaration.parent.kind !== 187 /* FunctionBlock */) { + if (!ts.isFunctionBlock(functionDeclaration.parent)) { return true; } } @@ -17082,30 +18642,38 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 123 /* Parameter */: + case 124 /* Parameter */: + if (ts.isBindingPattern(node.name)) { + break; + } if ((node.flags & 243 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 125 /* Method */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 127 /* GetAccessor */: + case 130 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 128 /* SetAccessor */: + case 131 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 131 /* IndexSignature */: + case 134 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 196 /* EnumMember */: + case 206 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 129 /* CallSignature */: + case 132 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 130 /* ConstructSignature */: + case 133 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 124 /* Property */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 185 /* VariableDeclaration */: + case 189 /* VariableDeclaration */: + if (ts.isBindingPattern(node.name)) { + break; + } if (ts.isConst(node)) { return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.constElement); } @@ -17115,7 +18683,7 @@ var ts; else { return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.variableElement); } - case 126 /* Constructor */: + case 129 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); } return undefined; @@ -17145,27 +18713,27 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 197 /* SourceFile */: + case 207 /* SourceFile */: return createSourceFileItem(node); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: return createClassItem(node); - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: return createEnumItem(node); - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: return createModuleItem(node); - case 186 /* FunctionDeclaration */: + case 190 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 7 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 195 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -17177,7 +18745,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 187 /* FunctionBlock */) { + if (node.name && node.body && node.body.kind === 169 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -17196,30 +18764,36 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 126 /* Constructor */ && member; + return member.kind === 129 /* Constructor */ && member; }); - var nodes = constructor ? node.members.concat(constructor.parameters) : node.members; + var nodes = removeComputedProperties(node); + if (constructor) { + nodes.push.apply(nodes, constructor.parameters); + } var childItems = getItemsWorker(sortNodes(nodes), createChildItem); } return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createEnumItem(node) { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createIterfaceItem(node) { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } } + function removeComputedProperties(node) { + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 122 /* ComputedPropertyName */; }); + } function getInnermostModule(node) { - while (node.body.kind === 192 /* ModuleDeclaration */) { + while (node.body.kind === 195 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 197 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd()); + return node.kind === 207 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd()); } function getTextOfNode(node) { return ts.getTextOfNodeFromSourceText(sourceFile.text, node); @@ -17252,9 +18826,9 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 147 /* CallExpression */ || node.parent.kind === 148 /* NewExpression */) { + if (node.parent.kind === 151 /* CallExpression */ || node.parent.kind === 152 /* NewExpression */) { var callExpression = node.parent; - if (node.kind === 23 /* LessThanToken */ || node.kind === 15 /* OpenParenToken */) { + if (node.kind === 24 /* LessThanToken */ || node.kind === 16 /* OpenParenToken */) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -17280,24 +18854,24 @@ var ts; }; } } - else if (node.kind === 9 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 153 /* TaggedTemplateExpression */) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 10 /* TemplateHead */ && node.parent.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 153 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 165 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 159 /* TemplateSpan */ && node.parent.parent.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 168 /* TemplateSpan */ && node.parent.parent.parent.kind === 153 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */); - if (node.kind === 12 /* TemplateTail */ && position >= node.getEnd() && !ts.isUnterminatedTemplateEnd(node)) { + ts.Debug.assert(templateExpression.kind === 165 /* TemplateExpression */); + if (node.kind === 13 /* TemplateTail */ && position >= node.getEnd() && !node.isUnterminated) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -17307,7 +18881,7 @@ var ts; return undefined; } function getCommaBasedArgCount(argumentsList) { - return argumentsList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentsList.getChildren(), function (arg) { return arg.kind === 22 /* CommaToken */; }); + return argumentsList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentsList.getChildren(), function (arg) { return arg.kind === 23 /* CommaToken */; }); } function getArgumentIndexForTemplatePiece(spanIndex, node) { ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); @@ -17320,7 +18894,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - var argumentCount = tagExpression.template.kind === 9 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; + var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; return { kind: 2 /* TaggedTemplateArguments */, invocation: tagExpression, @@ -17338,17 +18912,17 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 165 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.kind === 120 /* Missing */) { + if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); } } return new ts.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 197 /* SourceFile */; n = n.parent) { - if (n.kind === 187 /* FunctionBlock */) { + for (var n = node; n.kind !== 207 /* SourceFile */; n = n.parent) { + if (ts.isFunctionBlock(n)) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { @@ -17387,7 +18961,7 @@ var ts; var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTarget); + var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; @@ -17397,20 +18971,20 @@ var ts; prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(23 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(24 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(25 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts); } else { var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); }); suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts); @@ -17418,7 +18992,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(22 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -17438,7 +19012,7 @@ var ts; }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = !!(parameter.valueDeclaration.flags & 4 /* QuestionMark */); + var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), @@ -17532,24 +19106,13 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 199 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 209 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); return syntaxList; } ts.findContainingList = findContainingList; - function findListItemIndexContainingPosition(list, position) { - ts.Debug.assert(list.kind === 199 /* SyntaxList */); - var children = list.getChildren(); - for (var i = 0; i < children.length; i++) { - if (children[i].pos <= position && children[i].end > position) { - return i; - } - } - return -1; - } - ts.findListItemIndexContainingPosition = findListItemIndexContainingPosition; function getTouchingWord(sourceFile, position) { return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); } @@ -17647,7 +19210,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 197 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 207 /* SourceFile */); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -17663,434 +19226,240 @@ var ts; } ts.findPrecedingToken = findPrecedingToken; function nodeHasTokens(n) { - if (n.kind === 0 /* Unknown */) { - return false; - } return n.getWidth() !== 0; } + function getNodeModifiers(node) { + var flags = node.flags; + var result = []; + if (flags & 32 /* Private */) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 64 /* Protected */) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16 /* Public */) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 128 /* Static */) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 1 /* Export */) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 132 /* TypeReference */ || node.kind === 147 /* CallExpression */) { + if (node.kind === 135 /* TypeReference */ || node.kind === 151 /* CallExpression */) { return node.typeArguments; } - if (ts.isAnyFunction(node) || node.kind === 188 /* ClassDeclaration */ || node.kind === 189 /* InterfaceDeclaration */) { + if (ts.isAnyFunction(node) || node.kind === 191 /* ClassDeclaration */ || node.kind === 192 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 1 /* FirstToken */ && n.kind <= 119 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 120 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 63 /* Identifier */ || ts.isKeyword(kind); + return kind === 64 /* Identifier */ || ts.isKeyword(kind); } function isPropertyName(kind) { - return kind === 7 /* StringLiteral */ || kind === 6 /* NumericLiteral */ || isWord(kind); + return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 13 /* FirstPunctuation */ <= kind && kind <= 62 /* LastPunctuation */; + return 14 /* FirstPunctuation */ <= kind && kind <= 63 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { - return (node.getStart() < position && position < node.getEnd()) || (ts.isUnterminatedTemplateEnd(node) && position === node.getEnd()); + return ts.isTemplateLiteralKind(node.kind) && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var SmartIndenter; - (function (SmartIndenter) { - function getIndentation(position, sourceFile, options) { - if (position > sourceFile.text.length) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return 0; - } - if ((precedingToken.kind === 7 /* StringLiteral */ || precedingToken.kind === 8 /* RegularExpressionLiteral */) && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; - } - var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line; - if (precedingToken.kind === 22 /* CommaToken */ && precedingToken.parent.kind !== 156 /* BinaryExpression */) { - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - } - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; - } - break; - } - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - previous = current; - current = current.parent; - } - if (!current) { - return 0; - } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); - } - SmartIndenter.getIndentation = getIndentation; - function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { - var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); - } - SmartIndenter.getIndentationForNode = getIndentationForNode; - function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta; - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterFromPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile)); - } - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - var commaItemInfo = ts.findListItemInfo(commaToken); - ts.Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0); - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 197 /* SourceFile */ || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); - } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { return false; } - if (nextToken.kind === 13 /* OpenBraceToken */) { - return true; - } - else if (nextToken.kind === 14 /* CloseBraceToken */) { - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; - } - return false; } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); - } - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 166 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 74 /* ElseKeyword */, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; - } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 132 /* TypeReference */: - if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 142 /* ObjectLiteral */: - return node.parent.properties; - case 141 /* ArrayLiteral */: - return node.parent.elements; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 129 /* CallSignature */: - case 130 /* 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; - case 148 /* NewExpression */: - case 147 /* CallExpression */: - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; } } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); - for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 22 /* CommaToken */) { - continue; - } - var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); - } - return -1; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - var column = 0; - for (var pos = startPos; pos < endPos; ++pos) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch)) { - return column; - } - if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); - } - else { - column++; - } - } - return column; - } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 141 /* ArrayLiteral */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: - case 142 /* ObjectLiteral */: - case 136 /* TypeLiteral */: - case 175 /* SwitchStatement */: - case 177 /* DefaultClause */: - case 176 /* CaseClause */: - case 151 /* ParenExpression */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 163 /* VariableStatement */: - case 185 /* VariableDeclaration */: - case 195 /* ExportAssignment */: - case 173 /* ReturnStatement */: - return true; - } - return false; - } - function shouldIndentChildNode(parent, child) { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - return child !== 162 /* Block */; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return child !== 187 /* FunctionBlock */; - default: - return false; - } - } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 21 /* SemicolonToken */ && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function isCompletedNode(n, sourceFile) { - switch (n.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 142 /* ObjectLiteral */: - case 162 /* Block */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 175 /* SwitchStatement */: - return nodeEndsWith(n, 14 /* CloseBraceToken */, sourceFile); - case 151 /* ParenExpression */: - case 129 /* CallSignature */: - case 147 /* CallExpression */: - case 130 /* ConstructSignature */: - return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - return !n.body || isCompletedNode(n.body, sourceFile); - case 192 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 166 /* IfStatement */: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 165 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 141 /* ArrayLiteral */: - return nodeEndsWith(n, 18 /* CloseBracketToken */, sourceFile); - case 120 /* Missing */: - return false; - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return false; - case 168 /* WhileStatement */: - return isCompletedNode(n.statement, sourceFile); - case 167 /* DoStatement */: - var hasWhileKeyword = ts.findChildOfKind(n, 98 /* WhileKeyword */, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - default: - return true; - } - } - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); - })(formatting = ts.formatting || (ts.formatting = {})); + } + return true; + } + ts.compareDataObjects = compareDataObjects; })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - var tabString; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - return spaces ? tabString + repeat(" ", spaces) : tabString; + function isFirstDeclarationOfSymbolParameter(symbol) { + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 124 /* Parameter */; + } + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, 5 /* keyword */); }, + writeOperator: function (text) { return writeKind(text, 12 /* operator */); }, + writePunctuation: function (text) { return writeKind(text, 15 /* punctuation */); }, + writeSpace: function (text) { return writeKind(text, 16 /* space */); }, + writeStringLiteral: function (text) { return writeKind(text, 8 /* stringLiteral */); }, + writeParameter: function (text) { return writeKind(text, 13 /* parameterName */); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { + indent++; + }, + decreaseIndent: function () { + indent--; + }, + clear: resetWriter, + trackSymbol: function () { } - else { - var spacesString; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, 16 /* space */)); } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - return s; + lineStart = false; } } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3 /* Variable */) { + return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; + } + else if (flags & 4 /* Property */) { + return 14 /* propertyName */; + } + else if (flags & 32768 /* GetAccessor */) { + return 14 /* propertyName */; + } + else if (flags & 65536 /* SetAccessor */) { + return 14 /* propertyName */; + } + else if (flags & 8 /* EnumMember */) { + return 19 /* enumMemberName */; + } + else if (flags & 16 /* Function */) { + return 20 /* functionName */; + } + else if (flags & 32 /* Class */) { + return 1 /* className */; + } + else if (flags & 64 /* Interface */) { + return 4 /* interfaceName */; + } + else if (flags & 384 /* Enum */) { + return 2 /* enumName */; + } + else if (flags & 1536 /* Module */) { + return 11 /* moduleName */; + } + else if (flags & 8192 /* Method */) { + return 10 /* methodName */; + } + else if (flags & 262144 /* TypeParameter */) { + return 18 /* typeParameterName */; + } + else if (flags & 524288 /* TypeAlias */) { + return 0 /* aliasName */; + } + else if (flags & 8388608 /* Import */) { + return 0 /* aliasName */; + } + return 17 /* text */; + } + } + ts.symbolPart = symbolPart; + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", 16 /* space */); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), 5 /* keyword */); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), 15 /* punctuation */); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), 12 /* operator */); + } + ts.operatorPart = operatorPart; + function textPart(text) { + return displayPart(text, 17 /* text */); + } + ts.textPart = textPart; + function lineBreakPart() { + return displayPart("\n", 6 /* lineBreak */); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; })(ts || (ts = {})); var ts; (function (ts) { @@ -18155,27 +19524,27 @@ var ts; savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(container) { - if (container.kind !== 156 /* BinaryExpression */) { + if (container.kind !== 163 /* BinaryExpression */) { return false; } switch (container.operator) { - case 26 /* GreaterThanEqualsToken */: - case 58 /* GreaterThanGreaterThanEqualsToken */: - case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - case 40 /* GreaterThanGreaterThanToken */: + case 27 /* GreaterThanEqualsToken */: + case 59 /* GreaterThanGreaterThanEqualsToken */: + case 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 41 /* GreaterThanGreaterThanToken */: return true; } return false; } function shouldRescanSlashToken(container) { - return container.kind === 8 /* RegularExpressionLiteral */; + return container.kind === 9 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 159 /* TemplateSpan */; + return container.kind === 12 /* TemplateMiddle */ || container.kind === 13 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 35 /* SlashToken */ || t === 55 /* SlashEqualsToken */; + return t === 36 /* SlashToken */ || t === 56 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -18187,7 +19556,7 @@ var ts; } var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { - return lastTokenInfo; + return fixTokenKind(lastTokenInfo, n); } if (scanner.getStartPos() !== savedPos) { ts.Debug.assert(lastTokenInfo !== undefined); @@ -18195,7 +19564,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 24 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 25 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.operator === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -18205,7 +19574,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 14 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } @@ -18236,17 +19605,24 @@ var ts; break; } } - return lastTokenInfo = { + lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; + return fixTokenKind(lastTokenInfo, n); } function isOnToken() { 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); } + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; + } + return tokenInfo; + } } formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); @@ -18315,8 +19691,8 @@ var ts; return startLine == endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 13 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 14 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterFromPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterFromPosition(closeBrace.getStart(this.sourceFile)).line; @@ -18443,70 +19819,70 @@ var ts; function Rules() { 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 */)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 49 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQMark = new formatting.Rule(formatting.RuleDescriptor.create3(49 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* CloseBraceToken */, 74 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* CloseBraceToken */, 98 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([16 /* CloseParenToken */, 18 /* CloseBracketToken */, 22 /* CommaToken */, 21 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQMark = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 75 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 99 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([63 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([16 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 73 /* DoKeyword */, 94 /* TryKeyword */, 79 /* FinallyKeyword */, 74 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(13 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 14 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(13 /* OpenBraceToken */, 14 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(13 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 14 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([64 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 74 /* DoKeyword */, 95 /* TryKeyword */, 80 /* FinallyKeyword */, 75 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 37 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 38 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* PlusPlusToken */, 32 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(32 /* PlusToken */, 32 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(32 /* PlusToken */, 37 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* MinusMinusToken */, 33 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* MinusToken */, 33 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* MinusToken */, 38 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([96 /* VarKeyword */, 92 /* ThrowKeyword */, 86 /* NewKeyword */, 72 /* DeleteKeyword */, 88 /* ReturnKeyword */, 95 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(81 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(97 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* ReturnKeyword */, 21 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([16 /* CloseParenToken */, 73 /* DoKeyword */, 74 /* ElseKeyword */, 65 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([94 /* TryKeyword */, 79 /* FinallyKeyword */]), 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([113 /* GetKeyword */, 117 /* SetKeyword */]), 63 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* PlusPlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* MinusMinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([97 /* VarKeyword */, 93 /* ThrowKeyword */, 87 /* NewKeyword */, 73 /* DeleteKeyword */, 89 /* ReturnKeyword */, 96 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(82 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(98 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 74 /* DoKeyword */, 75 /* ElseKeyword */, 66 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([95 /* TryKeyword */, 80 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([114 /* GetKeyword */, 118 /* SetKeyword */]), 64 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* ConstructorKeyword */, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([114 /* ModuleKeyword */, 115 /* RequireKeyword */]), 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([67 /* ClassKeyword */, 112 /* DeclareKeyword */, 75 /* EnumKeyword */, 76 /* ExportKeyword */, 77 /* ExtendsKeyword */, 113 /* GetKeyword */, 100 /* ImplementsKeyword */, 83 /* ImportKeyword */, 101 /* InterfaceKeyword */, 114 /* ModuleKeyword */, 104 /* PrivateKeyword */, 106 /* PublicKeyword */, 117 /* SetKeyword */, 107 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([77 /* ExtendsKeyword */, 100 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(7 /* StringLiteral */, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(31 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* DotDotDotToken */, 63 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(49 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([16 /* CloseParenToken */, 22 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 23 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseParenToken */, 23 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([15 /* OpenParenToken */, 17 /* OpenBracketToken */, 24 /* GreaterThanToken */, 22 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(13 /* OpenBraceToken */, 14 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([115 /* ModuleKeyword */, 116 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([68 /* ClassKeyword */, 113 /* DeclareKeyword */, 76 /* EnumKeyword */, 77 /* ExportKeyword */, 78 /* ExtendsKeyword */, 114 /* GetKeyword */, 101 /* ImplementsKeyword */, 84 /* ImportKeyword */, 102 /* InterfaceKeyword */, 115 /* ModuleKeyword */, 105 /* PrivateKeyword */, 107 /* PublicKeyword */, 118 /* SetKeyword */, 108 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([78 /* ExtendsKeyword */, 101 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 64 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 25 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -18574,26 +19950,26 @@ var ts; this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 13 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenParenToken */, 16 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(81 /* FunctionKeyword */, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(81 /* FunctionKeyword */, 15 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(82 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -18605,24 +19981,25 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 169 /* ForStatement */; + return context.contextNode.kind === 176 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: + case 163 /* BinaryExpression */: + case 164 /* ConditionalExpression */: return true; - case 194 /* ImportDeclaration */: - case 185 /* VariableDeclaration */: - case 123 /* Parameter */: - case 196 /* EnumMember */: - case 124 /* Property */: - return context.currentTokenSpan.kind === 51 /* EqualsToken */ || context.nextTokenSpan.kind === 51 /* EqualsToken */; - case 170 /* ForInStatement */: - return context.currentTokenSpan.kind === 84 /* InKeyword */ || context.nextTokenSpan.kind === 84 /* InKeyword */; + case 197 /* ImportDeclaration */: + case 189 /* VariableDeclaration */: + case 124 /* Parameter */: + case 206 /* EnumMember */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return context.currentTokenSpan.kind === 52 /* EqualsToken */ || context.nextTokenSpan.kind === 52 /* EqualsToken */; + case 177 /* ForInStatement */: + return context.currentTokenSpan.kind === 85 /* InKeyword */ || context.nextTokenSpan.kind === 85 /* InKeyword */; } return false; }; @@ -18652,29 +20029,28 @@ var ts; return true; } switch (node.kind) { - case 162 /* Block */: - case 175 /* SwitchStatement */: - case 142 /* ObjectLiteral */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 169 /* Block */: + case 182 /* SwitchStatement */: + case 148 /* ObjectLiteralExpression */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 129 /* CallSignature */: - case 152 /* FunctionExpression */: - case 126 /* Constructor */: - case 153 /* ArrowFunction */: - case 189 /* InterfaceDeclaration */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 132 /* CallSignature */: + case 156 /* FunctionExpression */: + case 129 /* Constructor */: + case 157 /* ArrowFunction */: + case 192 /* InterfaceDeclaration */: return true; } return false; @@ -18684,60 +20060,62 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 136 /* TypeLiteral */: - case 192 /* ModuleDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 139 /* TypeLiteral */: + case 195 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 188 /* ClassDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 175 /* SwitchStatement */: + case 191 /* ClassDeclaration */: + case 195 /* ModuleDeclaration */: + case 194 /* EnumDeclaration */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: + case 182 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 166 /* IfStatement */: - case 175 /* SwitchStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 168 /* WhileStatement */: - case 180 /* TryStatement */: - case 167 /* DoStatement */: - case 174 /* WithStatement */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 173 /* IfStatement */: + case 182 /* SwitchStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 175 /* WhileStatement */: + case 185 /* TryStatement */: + case 174 /* DoStatement */: + case 181 /* WithStatement */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 142 /* ObjectLiteral */; + return context.contextNode.kind === 148 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 147 /* CallExpression */; + return context.contextNode.kind === 151 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 148 /* NewExpression */; + return context.contextNode.kind === 152 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; + Rules.IsPreviousTokenNotComma = function (context) { + return context.currentTokenSpan.kind !== 23 /* CommaToken */; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -18745,27 +20123,28 @@ var ts; return context.formattingRequestKind != 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 192 /* ModuleDeclaration */; + return context.contextNode.kind === 195 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 136 /* TypeLiteral */; + return context.contextNode.kind === 139 /* TypeLiteral */; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 23 /* LessThanToken */ && token.kind !== 24 /* GreaterThanToken */) { + if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 132 /* TypeReference */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 135 /* TypeReference */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return true; default: return false; @@ -18775,7 +20154,7 @@ var ts; return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 97 /* VoidKeyword */ && context.currentTokenParent.kind === 154 /* PrefixOperator */; + return context.currentTokenSpan.kind === 98 /* VoidKeyword */ && context.currentTokenParent.kind === 160 /* VoidExpression */; }; return Rules; })(); @@ -18797,7 +20176,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 119 /* LastToken */ + 1; + this.mapRowLength = 120 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -18965,7 +20344,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 1 /* FirstToken */; token <= 119 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 120 /* LastToken */; token++) { result.push(token); } return result; @@ -19007,46 +20386,25 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(64 /* FirstKeyword */, 119 /* LastKeyword */); - TokenRange.Operators = TokenRange.FromRange(21 /* FirstOperator */, 62 /* LastOperator */); - TokenRange.BinaryOperators = TokenRange.FromRange(23 /* FirstBinaryOperator */, 62 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([84 /* InKeyword */, 85 /* InstanceOfKeyword */]); - TokenRange.ReservedKeywords = TokenRange.FromRange(100 /* FirstFutureReservedWord */, 108 /* LastFutureReservedWord */); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([37 /* PlusPlusToken */, 38 /* MinusMinusToken */, 46 /* TildeToken */, 45 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([6 /* NumericLiteral */, 63 /* Identifier */, 15 /* OpenParenToken */, 17 /* OpenBracketToken */, 13 /* OpenBraceToken */, 91 /* ThisKeyword */, 86 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([63 /* Identifier */, 15 /* OpenParenToken */, 91 /* ThisKeyword */, 86 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([63 /* Identifier */, 16 /* CloseParenToken */, 18 /* CloseBracketToken */, 86 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([63 /* Identifier */, 15 /* OpenParenToken */, 91 /* ThisKeyword */, 86 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([63 /* Identifier */, 16 /* CloseParenToken */, 18 /* CloseBracketToken */, 86 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(65 /* FirstKeyword */, 120 /* LastKeyword */); + TokenRange.Operators = TokenRange.FromRange(22 /* FirstOperator */, 63 /* LastOperator */); + TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 63 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([85 /* InKeyword */, 86 /* InstanceOfKeyword */]); + TokenRange.ReservedKeywords = TokenRange.FromRange(101 /* FirstFutureReservedWord */, 109 /* LastFutureReservedWord */); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 64 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 92 /* ThisKeyword */, 87 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([64 /* Identifier */, 16 /* OpenParenToken */, 92 /* ThisKeyword */, 87 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([64 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 87 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([64 /* Identifier */, 16 /* OpenParenToken */, 92 /* ThisKeyword */, 87 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([64 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 87 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([63 /* Identifier */, 116 /* NumberKeyword */, 118 /* StringKeyword */, 110 /* BooleanKeyword */, 97 /* VoidKeyword */, 109 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([64 /* Identifier */, 117 /* NumberKeyword */, 119 /* StringKeyword */, 111 /* BooleanKeyword */, 98 /* VoidKeyword */, 110 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var TokenSpan = (function (_super) { - __extends(TokenSpan, _super); - function TokenSpan(kind, start, length) { - _super.call(this, start, length); - this.kind = kind; - } - return TokenSpan; - })(ts.TextSpan); - formatting.TokenSpan = TokenSpan; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); var ts; (function (ts) { var formatting; @@ -19148,11 +20506,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 21 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 14 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -19195,19 +20553,20 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 162 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 197 /* SourceFile */: - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + return body && body.kind === 169 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 207 /* SourceFile */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); + case 203 /* CatchClause */: + return ts.rangeContainsRange(parent.block.statements, node); } return false; } @@ -19228,7 +20587,7 @@ var ts; if (!errors.length) { return rangeHasNoErrors; } - var sorted = errors.filter(function (d) { return d.isParseError && ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }).sort(function (e1, e2) { return e1.start - e2.start; }); + var sorted = errors.filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }).sort(function (e1, e2) { return e1.start - e2.start; }); if (!sorted.length) { return rangeHasNoErrors; } @@ -19260,8 +20619,25 @@ var ts; var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); return precedingToken ? precedingToken.end : enclosingNode.pos; } + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1 /* Unknown */; + var childKind = 0 /* Unknown */; + while (n) { + var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + break; + } + if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + return options.IndentSize; + } + previousLine = line; + childKind = n.kind; + n = n.parent; + } + return 0; + } function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.getSyntacticDiagnostics(), originalRange); + 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); @@ -19274,7 +20650,7 @@ var ts; formattingScanner.advance(); if (formattingScanner.isOnToken()) { var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line; - var delta = formatting.SmartIndenter.shouldIndentChildNode(enclosingNode.kind, 0 /* Unknown */) ? options.IndentSize : 0; + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta); } formattingScanner.close(); @@ -19299,7 +20675,7 @@ var ts; var indentation = inheritedIndentation; if (indentation === -1 /* Unknown */) { if (isSomeBlock(node.kind)) { - if (isSomeBlock(parent.kind) || parent.kind === 197 /* SourceFile */ || parent.kind === 176 /* CaseClause */ || parent.kind === 177 /* DefaultClause */) { + if (isSomeBlock(parent.kind) || parent.kind === 207 /* SourceFile */ || parent.kind === 200 /* CaseClause */ || parent.kind === 201 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -19329,20 +20705,20 @@ var ts; return { getIndentationForComment: function (kind) { switch (kind) { - case 14 /* CloseBraceToken */: - case 18 /* CloseBracketToken */: + case 15 /* CloseBraceToken */: + case 19 /* CloseBracketToken */: return indentation + delta; } return indentation; }, getIndentationForToken: function (line, kind) { switch (kind) { - case 13 /* OpenBraceToken */: - case 14 /* CloseBraceToken */: - case 17 /* OpenBracketToken */: - case 18 /* CloseBracketToken */: - case 74 /* ElseKeyword */: - case 98 /* WhileKeyword */: + case 14 /* OpenBraceToken */: + case 15 /* CloseBraceToken */: + case 18 /* OpenBracketToken */: + case 19 /* CloseBracketToken */: + case 75 /* ElseKeyword */: + case 99 /* WhileKeyword */: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -19399,7 +20775,7 @@ var ts; if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { return inheritedIndentation; } - if (child.kind === 120 /* Missing */) { + if (child.getFullWidth() === 0) { return inheritedIndentation; } while (formattingScanner.isOnToken()) { @@ -19413,7 +20789,7 @@ var ts; return inheritedIndentation; } if (ts.isToken(child)) { - var tokenInfo = formattingScanner.readTokenInfo(node); + var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; @@ -19469,13 +20845,19 @@ var ts; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos); if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); var prevStartLine = previousRangeStartLine; lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (lineAdded !== undefined) { - indentToken = lineAdded; + if (rangeHasError) { + indentToken = false; } else { - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + } } } if (currentTokenInfo.trailingTrivia) { @@ -19553,18 +20935,17 @@ var ts; if (rule) { applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { + lineAdded = false; if (currentParent.getStart(sourceFile) === currentItem.pos) { - lineAdded = false; + dynamicIndentation.recomputeIndentation(false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { + lineAdded = true; if (currentParent.getStart(sourceFile) === currentItem.pos) { - lineAdded = true; + dynamicIndentation.recomputeIndentation(true); } } - if (lineAdded !== undefined) { - dynamicIndentation.recomputeIndentation(lineAdded); - } trimTrailingWhitespaces = (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && rule.Flag !== 1 /* CanDeleteNewLines */; } else { @@ -19576,7 +20957,7 @@ var ts; return lineAdded; } function insertIndentation(pos, indentation, lineAdded) { - var indentationString = formatting.getIndentationString(indentation, options); + var indentationString = getIndentationString(indentation, options); if (lineAdded) { recordReplace(pos, 0, indentationString); } @@ -19623,7 +21004,7 @@ var ts; var nonWhitespaceColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceColumn(parts[i].pos, parts[i].end, sourceFile, options); var newIndentation = nonWhitespaceColumn + delta; if (newIndentation > 0) { - var indentationString = formatting.getIndentationString(newIndentation, options); + var indentationString = getIndentationString(newIndentation, options); recordReplace(startLinePos, nonWhitespaceColumn, indentationString); } else { @@ -19694,59 +21075,453 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + case 169 /* Block */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: + case 129 /* Constructor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 157 /* ArrowFunction */: if (node.typeParameters === list) { - return 23 /* LessThanToken */; + return 24 /* LessThanToken */; } else if (node.parameters === list) { - return 15 /* OpenParenToken */; + return 16 /* OpenParenToken */; } break; - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: if (node.typeArguments === list) { - return 23 /* LessThanToken */; + return 24 /* LessThanToken */; } else if (node.arguments === list) { - return 15 /* OpenParenToken */; + return 16 /* OpenParenToken */; } break; - case 132 /* TypeReference */: + case 135 /* TypeReference */: if (node.typeArguments === list) { - return 23 /* LessThanToken */; + return 24 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 15 /* OpenParenToken */: - return 16 /* CloseParenToken */; - case 23 /* LessThanToken */: - return 24 /* GreaterThanToken */; + case 16 /* OpenParenToken */: + return 17 /* CloseParenToken */; + case 24 /* LessThanToken */: + return 25 /* GreaterThanToken */; } return 0 /* Unknown */; } + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + if (!options.ConvertTabsToSpaces) { + var tabs = Math.floor(indentation / options.TabSize); + var spaces = indentation - tabs * options.TabSize; + var tabString; + if (!internedTabsIndentation) { + internedTabsIndentation = []; + } + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); + } + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString; + var quotient = Math.floor(indentation / options.IndentSize); + var remainder = indentation % options.IndentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.IndentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; + } + else { + spacesString = internedSpacesIndentation[quotient]; + } + return remainder ? spacesString + repeat(" ", remainder) : spacesString; + } + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; ++i) { + s += value; + } + return s; + } + } + formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; (function (ts) { + var formatting; + (function (formatting) { + var SmartIndenter; + (function (SmartIndenter) { + function getIndentation(position, sourceFile, options) { + if (position > sourceFile.text.length) { + return 0; + } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return 0; + } + if ((precedingToken.kind === 8 /* StringLiteral */ || precedingToken.kind === 9 /* RegularExpressionLiteral */) && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; + } + var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line; + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 163 /* BinaryExpression */) { + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + } + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + } + break; + } + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + previous = current; + current = current.parent; + } + if (!current) { + return 0; + } + return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { + var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + } + SmartIndenter.getIndentationForNode = getIndentationForNode; + function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; + } + current = parent; + currentStart = parentStart; + parent = current.parent; + } + return indentationDelta; + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterFromPosition(containingList.pos); + } + return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile)); + } + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + var commaItemInfo = ts.findListItemInfo(commaToken); + ts.Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0); + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); + } + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 207 /* SourceFile */ || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1; + } + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { + return false; + } + if (nextToken.kind === 14 /* OpenBraceToken */) { + return true; + } + else if (nextToken.kind === 15 /* CloseBraceToken */) { + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; + } + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); + } + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 173 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 75 /* ElseKeyword */, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; + } + return false; + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 135 /* TypeReference */: + if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 148 /* ObjectLiteralExpression */: + return node.parent.properties; + case 147 /* ArrayLiteralExpression */: + return node.parent.elements; + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 132 /* CallSignature */: + case 133 /* 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; + case 152 /* NewExpression */: + case 151 /* 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 undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + } + } + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); + for (var i = index - 1; i >= 0; --i) { + if (list[i].kind === 23 /* CommaToken */) { + continue; + } + var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); + } + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + } + return -1; + } + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + var column = 0; + for (var pos = startPos; pos < endPos; ++pos) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch)) { + return column; + } + if (ch === 9 /* tab */) { + column += options.TabSize + (column % options.TabSize); + } + else { + column++; + } + } + return column; + } + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 147 /* ArrayLiteralExpression */: + case 169 /* Block */: + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: + case 148 /* ObjectLiteralExpression */: + case 139 /* TypeLiteral */: + case 182 /* SwitchStatement */: + case 201 /* DefaultClause */: + case 200 /* CaseClause */: + case 155 /* ParenthesizedExpression */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: + case 170 /* VariableStatement */: + case 189 /* VariableDeclaration */: + case 198 /* ExportAssignment */: + case 180 /* ReturnStatement */: + case 164 /* ConditionalExpression */: + return true; + } + return false; + } + function shouldIndentChildNode(parent, child) { + if (nodeContentIsAlwaysIndented(parent)) { + return true; + } + switch (parent) { + case 174 /* DoStatement */: + case 175 /* WhileStatement */: + case 177 /* ForInStatement */: + case 176 /* ForStatement */: + case 173 /* IfStatement */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 157 /* ArrowFunction */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + return child !== 169 /* Block */; + default: + return false; + } + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function isCompletedNode(n, sourceFile) { + if (n.getFullWidth() === 0) { + return false; + } + switch (n.kind) { + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 148 /* ObjectLiteralExpression */: + case 169 /* Block */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: + case 182 /* SwitchStatement */: + return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); + case 203 /* CatchClause */: + return isCompletedNode(n.block, sourceFile); + case 155 /* ParenthesizedExpression */: + case 132 /* CallSignature */: + case 151 /* CallExpression */: + case 133 /* ConstructSignature */: + return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 157 /* ArrowFunction */: + return !n.body || isCompletedNode(n.body, sourceFile); + case 195 /* ModuleDeclaration */: + return n.body && isCompletedNode(n.body, sourceFile); + case 173 /* IfStatement */: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 172 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile); + case 147 /* ArrayLiteralExpression */: + return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); + case 200 /* CaseClause */: + case 201 /* DefaultClause */: + return false; + case 175 /* WhileStatement */: + return isCompletedNode(n.statement, sourceFile); + case 174 /* DoStatement */: + var hasWhileKeyword = ts.findChildOfKind(n, 99 /* WhileKeyword */, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + default: + return true; + } + } + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var ts; +(function (ts) { + ts.servicesVersion = "0.4"; var ScriptSnapshot; (function (ScriptSnapshot) { var StringScriptSnapshot = (function () { @@ -19827,7 +21602,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(199 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); + var list = createNode(209 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var i = 0, len = nodes.length; i < len; i++) { @@ -19845,7 +21620,7 @@ var ts; }; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; - if (this.kind > 120 /* Missing */) { + if (this.kind >= 121 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); var children = []; var pos = this.pos; @@ -19890,20 +21665,20 @@ var ts; var children = this.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (child.kind < 120 /* Missing */) + if (child.kind < 121 /* FirstNode */) { return child; - if (child.kind > 120 /* Missing */) - return child.getFirstToken(sourceFile); + } + return child.getFirstToken(sourceFile); } }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 120 /* Missing */) + if (child.kind < 121 /* FirstNode */) { return child; - if (child.kind > 120 /* Missing */) - return child.getLastToken(sourceFile); + } + return child.getLastToken(sourceFile); } }; return NodeObject; @@ -19935,7 +21710,7 @@ var ts; var docComments = getJsDocCommentsSeparatedByNewLines(); ts.forEach(docComments, function (docComment) { if (documentationComment.length) { - documentationComment.push(lineBreakPart()); + documentationComment.push(ts.lineBreakPart()); } documentationComment.push(docComment); }); @@ -19945,7 +21720,7 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 123 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 124 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -19953,13 +21728,13 @@ var ts; } }); } - if (declaration.kind === 192 /* ModuleDeclaration */ && declaration.body.kind === 192 /* ModuleDeclaration */) { + if (declaration.kind === 195 /* ModuleDeclaration */ && declaration.body.kind === 195 /* ModuleDeclaration */) { return; } - while (declaration.kind === 192 /* ModuleDeclaration */ && declaration.parent.kind === 192 /* ModuleDeclaration */) { + while (declaration.kind === 195 /* ModuleDeclaration */ && declaration.parent.kind === 195 /* ModuleDeclaration */) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 185 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 189 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -20001,8 +21776,8 @@ var ts; } function pushDocCommentLineText(docComments, text, blankLineCount) { while (blankLineCount--) - docComments.push(textPart("")); - docComments.push(textPart(text)); + docComments.push(ts.textPart("")); + docComments.push(ts.textPart(text)); } function getCleanedJsDocComment(pos, end, sourceFile) { var spacesToRemoveAfterAsterisk; @@ -20230,10 +22005,11 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 186 /* FunctionDeclaration */: - case 125 /* Method */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: var functionDeclaration = node; - if (functionDeclaration.name && functionDeclaration.name.kind !== 120 /* Missing */) { + if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) { var lastDeclaration = namedDeclarations.length > 0 ? namedDeclarations[namedDeclarations.length - 1] : undefined; if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) { if (functionDeclaration.body && !lastDeclaration.body) { @@ -20241,36 +22017,48 @@ var ts; } } else { - namedDeclarations.push(node); + namedDeclarations.push(functionDeclaration); } ts.forEachChild(node, visit); } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 136 /* TypeLiteral */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 139 /* TypeLiteral */: if (node.name) { namedDeclarations.push(node); } - case 126 /* Constructor */: - case 163 /* VariableStatement */: - case 193 /* ModuleBlock */: - case 187 /* FunctionBlock */: + case 129 /* Constructor */: + case 170 /* VariableStatement */: + case 144 /* ObjectBindingPattern */: + case 145 /* ArrayBindingPattern */: + case 196 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 123 /* Parameter */: + case 169 /* Block */: + if (ts.isFunctionBlock(node)) { + ts.forEachChild(node, visit); + } + break; + case 124 /* Parameter */: if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } - case 185 /* VariableDeclaration */: - case 196 /* EnumMember */: - case 124 /* Property */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + if (ts.isBindingPattern(node.name)) { + ts.forEachChild(node.name, visit); + break; + } + case 206 /* EnumMember */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: namedDeclarations.push(node); break; } @@ -20293,15 +22081,131 @@ var ts; ts.Debug.assert(oldTextSuffix === newTextSuffix); } } - return SourceFileObject.createSourceFileObject(this.filename, scriptSnapshot, this.languageVersion, version, isOpen); + return createLanguageServiceSourceFile(this.filename, scriptSnapshot, this.languageVersion, version, isOpen, true); }; - SourceFileObject.createSourceFileObject = function (filename, scriptSnapshot, languageVersion, version, isOpen) { - var newSourceFile = ts.createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), languageVersion, version, isOpen); + SourceFileObject.createSourceFileObject = function (filename, scriptSnapshot, languageVersion, version, isOpen, setParentNodes) { + var newSourceFile = ts.createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), languageVersion, setParentNodes); + newSourceFile.version = version; + newSourceFile.isOpen = isOpen; newSourceFile.scriptSnapshot = scriptSnapshot; return newSourceFile; }; return SourceFileObject; })(NodeObject); + var TextSpan = (function () { + function TextSpan(start, length) { + ts.Debug.assert(start >= 0, "start"); + ts.Debug.assert(length >= 0, "length"); + this._start = start; + this._length = length; + } + TextSpan.prototype.toJSON = function (key) { + return { start: this._start, length: this._length }; + }; + TextSpan.prototype.start = function () { + return this._start; + }; + TextSpan.prototype.length = function () { + return this._length; + }; + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = Math.max(this._start, span._start); + var overlapEnd = Math.min(this.end(), span.end()); + return overlapStart < overlapEnd; + }; + TextSpan.prototype.overlap = function (span) { + var overlapStart = Math.max(this._start, span._start); + var overlapEnd = Math.min(this.end(), span.end()); + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + return undefined; + }; + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + TextSpan.prototype.intersection = function (span) { + var intersectStart = Math.max(this._start, span._start); + var intersectEnd = Math.min(this.end(), span.end()); + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + return undefined; + }; + TextSpan.fromBounds = function (start, end) { + ts.Debug.assert(start >= 0); + ts.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + ts.TextSpan = TextSpan; + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + ts.Debug.assert(newLength >= 0, "newLength"); + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + TextChangeRange.prototype.newSpan = function () { + return new TextSpan(this.span().start(), this.newLength()); + }; + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return new TextChangeRange(TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TextSpan(0, 0), 0); + return TextChangeRange; + })(); + ts.TextChangeRange = TextChangeRange; var TextChange = (function () { function TextChange() { } @@ -20408,6 +22312,7 @@ var ts; ClassificationTypeNames.interfaceName = "interface name"; ClassificationTypeNames.moduleName = "module name"; ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAlias = "type alias name"; return ClassificationTypeNames; })(); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -20425,170 +22330,25 @@ var ts; return ""; } ts.displayPartsToString = displayPartsToString; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, 5 /* keyword */); }, - writeOperator: function (text) { return writeKind(text, 12 /* operator */); }, - writePunctuation: function (text) { return writeKind(text, 15 /* punctuation */); }, - writeSpace: function (text) { return writeKind(text, 16 /* space */); }, - writeStringLiteral: function (text) { return writeKind(text, 8 /* stringLiteral */); }, - writeParameter: function (text) { return writeKind(text, 13 /* parameterName */); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { - indent++; - }, - decreaseIndent: function () { - indent--; - }, - clear: resetWriter, - trackSymbol: function () { - } - }; - function writeIndent() { - if (lineStart) { - displayParts.push(displayPart(ts.getIndentString(indent), 16 /* space */)); - lineStart = false; - } - } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); - } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; - } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; - } - } - function displayPart(text, kind, symbol) { - return { - text: text, - kind: SymbolDisplayPartKind[kind] - }; - } - function spacePart() { - return displayPart(" ", 16 /* space */); - } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), 5 /* keyword */); - } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), 15 /* punctuation */); - } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), 12 /* operator */); - } - ts.operatorPart = operatorPart; - function textPart(text) { - return displayPart(text, 17 /* text */); - } - ts.textPart = textPart; - function lineBreakPart() { - return displayPart("\n", 6 /* lineBreak */); - } - ts.lineBreakPart = lineBreakPart; - function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 123 /* Parameter */; - } function isLocalVariableOrFunction(symbol) { if (symbol.parent) { return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 152 /* FunctionExpression */) { + if (declaration.kind === 156 /* FunctionExpression */) { return true; } - if (declaration.kind !== 185 /* VariableDeclaration */ && declaration.kind !== 186 /* FunctionDeclaration */) { + if (declaration.kind !== 189 /* VariableDeclaration */ && declaration.kind !== 190 /* FunctionDeclaration */) { return false; } - for (var parent = declaration.parent; parent.kind !== 187 /* FunctionBlock */; parent = parent.parent) { - if (parent.kind === 197 /* SourceFile */ || parent.kind === 193 /* ModuleBlock */) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 207 /* SourceFile */ || parent.kind === 196 /* ModuleBlock */) { return false; } } return true; }); } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3 /* Variable */) { - return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; - } - else if (flags & 4 /* Property */) { - return 14 /* propertyName */; - } - else if (flags & 8 /* EnumMember */) { - return 19 /* enumMemberName */; - } - else if (flags & 16 /* Function */) { - return 20 /* functionName */; - } - else if (flags & 32 /* Class */) { - return 1 /* className */; - } - else if (flags & 64 /* Interface */) { - return 4 /* interfaceName */; - } - else if (flags & 384 /* Enum */) { - return 2 /* enumName */; - } - else if (flags & 1536 /* Module */) { - return 11 /* moduleName */; - } - else if (flags & 8192 /* Method */) { - return 10 /* methodName */; - } - else if (flags & 1048576 /* TypeParameter */) { - return 18 /* typeParameterName */; - } - return 17 /* text */; - } - } - ts.symbolPart = symbolPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; - } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); - } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); - } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); - } function getDefaultCompilerOptions() { return { target: 2 /* Latest */, @@ -20596,20 +22356,6 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - ts.compareDataObjects = compareDataObjects; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -20689,7 +22435,7 @@ var ts; HostCache.prototype.getChangeRange = function (filename, lastKnownVersion, oldScriptSnapshot) { var currentVersion = this.getVersion(filename); if (lastKnownVersion === currentVersion) { - return ts.TextChangeRange.unchanged; + return TextChangeRange.unchanged; } var scriptSnapshot = this.getScriptSnapshot(filename); return scriptSnapshot.getChangeRange(oldScriptSnapshot); @@ -20702,7 +22448,6 @@ var ts; this.currentFilename = ""; this.currentFileVersion = null; this.currentSourceFile = null; - this.hostCache = new HostCache(host); } SyntaxTreeCache.prototype.initialize = function (filename) { var start = new Date().getTime(); @@ -20713,20 +22458,18 @@ var ts; if (this.currentFilename !== filename) { var scriptSnapshot = this.hostCache.getScriptSnapshot(filename); var start = new Date().getTime(); - sourceFile = createSourceFileFromScriptSnapshot(filename, scriptSnapshot, getDefaultCompilerOptions(), version, true); + sourceFile = createLanguageServiceSourceFile(filename, scriptSnapshot, getDefaultCompilerOptions().target, version, true, true); this.host.log("SyntaxTreeCache.Initialize: createSourceFile: " + (new Date().getTime() - start)); var start = new Date().getTime(); - fixupParentReferences(sourceFile); this.host.log("SyntaxTreeCache.Initialize: fixupParentRefs : " + (new Date().getTime() - start)); } else if (this.currentFileVersion !== version) { var scriptSnapshot = this.hostCache.getScriptSnapshot(filename); var editRange = this.hostCache.getChangeRange(filename, this.currentFileVersion, this.currentSourceFile.getScriptSnapshot()); var start = new Date().getTime(); - sourceFile = !editRange ? createSourceFileFromScriptSnapshot(filename, scriptSnapshot, getDefaultCompilerOptions(), version, true) : this.currentSourceFile.update(scriptSnapshot, version, true, editRange); + sourceFile = !editRange ? createLanguageServiceSourceFile(filename, scriptSnapshot, getDefaultCompilerOptions().target, version, true, true) : this.currentSourceFile.update(scriptSnapshot, version, true, editRange); this.host.log("SyntaxTreeCache.Initialize: updateSourceFile: " + (new Date().getTime() - start)); var start = new Date().getTime(); - fixupParentReferences(sourceFile); this.host.log("SyntaxTreeCache.Initialize: fixupParentRefs : " + (new Date().getTime() - start)); } if (sourceFile) { @@ -20734,17 +22477,6 @@ var ts; this.currentFilename = filename; this.currentSourceFile = sourceFile; } - function fixupParentReferences(sourceFile) { - var parent = sourceFile; - function walk(n) { - n.parent = parent; - var saveParent = parent; - parent = n; - ts.forEachChild(n, walk); - parent = saveParent; - } - ts.forEachChild(sourceFile, walk); - } }; SyntaxTreeCache.prototype.getCurrentSourceFile = function (filename) { this.initialize(filename); @@ -20755,9 +22487,10 @@ var ts; }; return SyntaxTreeCache; })(); - function createSourceFileFromScriptSnapshot(filename, scriptSnapshot, settings, version, isOpen) { - return SourceFileObject.createSourceFileObject(filename, scriptSnapshot, settings.target, version, isOpen); + function createLanguageServiceSourceFile(filename, scriptSnapshot, scriptTarget, version, isOpen, setNodeParents) { + return SourceFileObject.createSourceFileObject(filename, scriptSnapshot, scriptTarget, version, isOpen, setNodeParents); } + ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; function createDocumentRegistry() { var buckets = {}; function getKeyFromCompilationSettings(settings) { @@ -20795,7 +22528,7 @@ var ts; var bucket = getBucketForCompilationSettings(compilationSettings, true); var entry = ts.lookUp(bucket, filename); if (!entry) { - var sourceFile = createSourceFileFromScriptSnapshot(filename, scriptSnapshot, compilationSettings, version, isOpen); + var sourceFile = createLanguageServiceSourceFile(filename, scriptSnapshot, compilationSettings.target, version, isOpen, false); bucket[filename] = entry = { sourceFile: sourceFile, refCount: 0, @@ -20857,17 +22590,17 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1 /* EndOfFileToken */) { - if (token === 83 /* ImportKeyword */) { + if (token === 84 /* ImportKeyword */) { token = scanner.scan(); - if (token === 63 /* Identifier */) { + if (token === 64 /* Identifier */) { token = scanner.scan(); - if (token === 51 /* EqualsToken */) { + if (token === 52 /* EqualsToken */) { token = scanner.scan(); - if (token === 115 /* RequireKeyword */) { + if (token === 116 /* RequireKeyword */) { token = scanner.scan(); - if (token === 15 /* OpenParenToken */) { + if (token === 16 /* OpenParenToken */) { token = scanner.scan(); - if (token === 7 /* StringLiteral */) { + if (token === 8 /* StringLiteral */) { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); importedFiles.push({ @@ -20892,27 +22625,9 @@ var ts; return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; } ts.preProcessFile = preProcessFile; - function getNodeModifiers(node) { - var flags = node.flags; - var result = []; - if (flags & 32 /* Private */) - result.push(ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) - result.push(ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) - result.push(ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) - result.push(ScriptElementKindModifier.staticModifier); - if (flags & 1 /* Export */) - result.push(ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 178 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 183 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -20920,13 +22635,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 63 /* Identifier */ && (node.parent.kind === 172 /* BreakStatement */ || node.parent.kind === 171 /* ContinueStatement */) && node.parent.label === node; + return node.kind === 64 /* Identifier */ && (node.parent.kind === 179 /* BreakStatement */ || node.parent.kind === 178 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 63 /* Identifier */ && node.parent.kind === 178 /* LabeledStatement */ && node.parent.label === node; + return node.kind === 64 /* Identifier */ && node.parent.kind === 183 /* LabeledStatement */ && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 178 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 183 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -20940,48 +22655,53 @@ var ts; return node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 145 /* PropertyAccess */ && node.parent.right === node; + return node && node.parent && node.parent.kind === 149 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 151 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 152 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 192 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 195 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 63 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node; + return node.kind === 64 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 63 /* Identifier */ || node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) && (node.parent.kind === 143 /* PropertyAssignment */ || node.parent.kind === 144 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 64 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && (node.parent.kind === 204 /* PropertyAssignment */ || node.parent.kind === 205 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) { + if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 192 /* ModuleDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 195 /* ModuleDeclaration */: return node.parent.name === node; - case 146 /* IndexedAccess */: - return node.parent.index === node; + case 150 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node)); + if (node.kind === 8 /* StringLiteral */) { + return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node); + } + return false; } function isInsideComment(sourceFile, token, position) { return position <= token.getStart(sourceFile) && (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); @@ -21005,7 +22725,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 64 /* FirstKeyword */; i <= 119 /* LastKeyword */; i++) { + for (var i = 65 /* FirstKeyword */; i <= 120 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -21022,10 +22742,10 @@ var ts; var useCaseSensitivefilenames = false; var sourceFilesByName = {}; var documentRegistry = documentRegistry; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken()); + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var activeCompletionSession; var writer = undefined; - if (!ts.localizedDiagnosticMessages) { + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } function getCanonicalFileName(filename) { @@ -21054,8 +22774,8 @@ var ts; getCanonicalFileName: function (filename) { return useCaseSensitivefilenames ? filename : filename.toLowerCase(); }, useCaseSensitiveFileNames: function () { return useCaseSensitivefilenames; }, getNewLine: function () { return "\r\n"; }, - getDefaultLibFilename: function () { - return host.getDefaultLibFilename(); + getDefaultLibFilename: function (options) { + return host.getDefaultLibFilename(options); }, writeFile: function (filename, data, writeByteOrderMark) { writer(filename, data, writeByteOrderMark); @@ -21081,7 +22801,7 @@ var ts; return false; } } - return compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); } function synchronizeHostData() { hostCache = new HostCache(host); @@ -21093,7 +22813,7 @@ var ts; if (oldProgram) { var oldSettings = program.getCompilerOptions(); var settingsChangeAffectsSyntax = oldSettings.target !== compilationSettings.target || oldSettings.module !== compilationSettings.module; - var changesInCompilationSettingsAffectSyntax = oldSettings && compilationSettings && !compareDataObjects(oldSettings, compilationSettings) && settingsChangeAffectsSyntax; + var changesInCompilationSettingsAffectSyntax = oldSettings && compilationSettings && !ts.compareDataObjects(oldSettings, compilationSettings) && settingsChangeAffectsSyntax; var oldSourceFiles = program.getSourceFiles(); for (var i = 0, n = oldSourceFiles.length; i < n; i++) { cancellationToken.throwIfCancellationRequested(); @@ -21146,7 +22866,7 @@ var ts; function getSyntacticDiagnostics(filename) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); - return program.getDiagnostics(getSourceFile(filename).getSourceFile()); + return program.getDiagnostics(getSourceFile(filename)); } function getSemanticDiagnostics(filename) { synchronizeHostData(); @@ -21195,7 +22915,7 @@ var ts; kindModifiers: getSymbolModifiers(symbol) }; } - function getCompletionsAtPosition(filename, position, isMemberCompletion) { + function getCompletionsAtPosition(filename, position) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); var syntacticStart = new Date().getTime(); @@ -21213,7 +22933,7 @@ var ts; var start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); host.log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); - if (previousToken && position <= previousToken.end && previousToken.kind === 63 /* Identifier */) { + if (previousToken && position <= previousToken.end && previousToken.kind === 64 /* Identifier */) { var start = new Date().getTime(); previousToken = ts.findPrecedingToken(previousToken.pos, sourceFile); host.log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - start)); @@ -21224,7 +22944,11 @@ var ts; } var node; var isRightOfDot; - if (previousToken && previousToken.kind === 19 /* DotToken */ && (previousToken.parent.kind === 145 /* PropertyAccess */ || previousToken.parent.kind === 121 /* QualifiedName */)) { + if (previousToken && previousToken.kind === 20 /* DotToken */ && previousToken.parent.kind === 149 /* PropertyAccessExpression */) { + node = previousToken.parent.expression; + isRightOfDot = true; + } + else if (previousToken && previousToken.kind === 20 /* DotToken */ && previousToken.parent.kind === 121 /* QualifiedName */) { node = previousToken.parent.left; isRightOfDot = true; } @@ -21244,10 +22968,10 @@ var ts; var semanticStart = new Date().getTime(); if (isRightOfDot) { var symbols = []; - isMemberCompletion = true; - if (node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */ || node.kind === 145 /* PropertyAccess */) { - var symbol = typeInfoResolver.getSymbolInfo(node); - if (symbol && symbol.flags & 33554432 /* Import */) { + var isMemberCompletion = true; + if (node.kind === 64 /* Identifier */ || node.kind === 121 /* QualifiedName */ || node.kind === 149 /* PropertyAccessExpression */) { + var symbol = typeInfoResolver.getSymbolAtLocation(node); + if (symbol && symbol.flags & 8388608 /* Import */) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } if (symbol && symbol.flags & 1952 /* HasExports */) { @@ -21258,7 +22982,7 @@ var ts; }); } } - var type = typeInfoResolver.getTypeOfNode(node); + var type = typeInfoResolver.getTypeAtLocation(node); if (type) { ts.forEach(type.getApparentProperties(), function (symbol) { if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { @@ -21284,7 +23008,7 @@ var ts; } else { isMemberCompletion = false; - var symbolMeanings = 3152352 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 33554432 /* Import */; + var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Import */; var symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } @@ -21318,43 +23042,25 @@ var ts; return result; } function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { - if (previousToken.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(previousToken.kind)) { + if (previousToken.kind === 8 /* StringLiteral */ || previousToken.kind === 9 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(previousToken.kind)) { var start = previousToken.getStart(); var end = previousToken.getEnd(); if (start < position && position < end) { return true; } else if (position === end) { - var width = end - start; - var text = previousToken.getSourceFile().text; - if (width <= 1 || text.charCodeAt(end - 2) === 92 /* backslash */) { - return true; - } - switch (previousToken.kind) { - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - return text.charCodeAt(start) !== text.charCodeAt(end - 1); - case 10 /* TemplateHead */: - case 11 /* TemplateMiddle */: - return text.charCodeAt(end - 1) !== 123 /* openBrace */ || text.charCodeAt(end - 2) !== 36 /* $ */; - case 12 /* TemplateTail */: - return text.charCodeAt(end - 1) !== 96 /* backtick */; - } - return false; + return !!previousToken.isUnterminated; } } - else if (previousToken.kind === 8 /* RegularExpressionLiteral */) { - return previousToken.getStart() < position && position < previousToken.getEnd(); - } return false; } function getContainingObjectLiteralApplicableForCompletion(previousToken) { if (previousToken) { var parent = previousToken.parent; switch (previousToken.kind) { - case 13 /* OpenBraceToken */: - case 22 /* CommaToken */: - if (parent && parent.kind === 142 /* ObjectLiteral */) { + case 14 /* OpenBraceToken */: + case 23 /* CommaToken */: + if (parent && parent.kind === 148 /* ObjectLiteralExpression */) { return parent; } break; @@ -21364,16 +23070,17 @@ var ts; } function isFunction(kind) { switch (kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 132 /* CallSignature */: + case 133 /* ConstructSignature */: + case 134 /* IndexSignature */: return true; } return false; @@ -21382,28 +23089,28 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 22 /* CommaToken */: - return containingNodeKind === 185 /* VariableDeclaration */ || containingNodeKind === 163 /* VariableStatement */ || containingNodeKind === 191 /* EnumDeclaration */ || isFunction(containingNodeKind); - case 15 /* OpenParenToken */: - return containingNodeKind === 182 /* CatchBlock */ || isFunction(containingNodeKind); - case 13 /* OpenBraceToken */: - return containingNodeKind === 191 /* EnumDeclaration */ || containingNodeKind === 189 /* InterfaceDeclaration */; - case 21 /* SemicolonToken */: - return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 189 /* InterfaceDeclaration */; - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 107 /* StaticKeyword */: - case 20 /* DotDotDotToken */: - return containingNodeKind === 123 /* Parameter */; - case 67 /* ClassKeyword */: - case 114 /* ModuleKeyword */: - case 75 /* EnumKeyword */: - case 101 /* InterfaceKeyword */: - case 81 /* FunctionKeyword */: - case 96 /* VarKeyword */: - case 113 /* GetKeyword */: - case 117 /* SetKeyword */: - case 83 /* ImportKeyword */: + case 23 /* CommaToken */: + return containingNodeKind === 189 /* VariableDeclaration */ || containingNodeKind === 170 /* VariableStatement */ || containingNodeKind === 194 /* EnumDeclaration */ || isFunction(containingNodeKind); + case 16 /* OpenParenToken */: + return containingNodeKind === 203 /* CatchClause */ || isFunction(containingNodeKind); + case 14 /* OpenBraceToken */: + return containingNodeKind === 194 /* EnumDeclaration */ || containingNodeKind === 192 /* InterfaceDeclaration */; + case 22 /* SemicolonToken */: + return containingNodeKind === 125 /* PropertySignature */ && previousToken.parent.parent.kind === 192 /* InterfaceDeclaration */; + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 108 /* StaticKeyword */: + case 21 /* DotDotDotToken */: + return containingNodeKind === 124 /* Parameter */; + case 68 /* ClassKeyword */: + case 115 /* ModuleKeyword */: + case 76 /* EnumKeyword */: + case 102 /* InterfaceKeyword */: + case 82 /* FunctionKeyword */: + case 97 /* VarKeyword */: + case 114 /* GetKeyword */: + case 118 /* SetKeyword */: + case 84 /* ImportKeyword */: return true; } switch (previousToken.getText()) { @@ -21419,7 +23126,7 @@ var ts; return false; } function isRightOfIllegalDot(previousToken) { - if (previousToken && previousToken.kind === 6 /* NumericLiteral */) { + if (previousToken && previousToken.kind === 7 /* NumericLiteral */) { var text = previousToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -21431,7 +23138,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 143 /* PropertyAssignment */ && m.kind !== 144 /* ShorthandPropertyAssignment */) { + if (m.kind !== 204 /* PropertyAssignment */ && m.kind !== 205 /* ShorthandPropertyAssignment */) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -21459,7 +23166,7 @@ var ts; if (symbol) { var location = ts.getTouchingPropertyName(sourceFile, position); var completionEntry = createCompletionEntry(symbol, session.typeChecker, location); - ts.Debug.assert(session.typeChecker.getNarrowedTypeOfSymbol(symbol, location) !== undefined, "Could not find type for symbol"); + ts.Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, location) !== undefined, "Could not find type for symbol"); var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, 7 /* All */); return { name: entryName, @@ -21474,7 +23181,7 @@ var ts; name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - displayParts: [displayPart(entryName, 5 /* keyword */)], + displayParts: [ts.displayPart(entryName, 5 /* keyword */)], documentation: undefined }; } @@ -21486,16 +23193,17 @@ var ts; return undefined; } switch (node.kind) { - case 197 /* SourceFile */: - case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: + case 207 /* SourceFile */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 191 /* ClassDeclaration */: + case 192 /* InterfaceDeclaration */: + case 194 /* EnumDeclaration */: + case 195 /* ModuleDeclaration */: return node; } } @@ -21506,20 +23214,22 @@ var ts; return ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; - if (flags & 2097152 /* TypeAlias */) + if (flags & 524288 /* TypeAlias */) return ScriptElementKind.typeElement; if (flags & 64 /* Interface */) return ScriptElementKind.interfaceElement; - if (flags & 1048576 /* TypeParameter */) + if (flags & 262144 /* TypeParameter */) return ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location); if (result === ScriptElementKind.unknown) { - if (flags & 1048576 /* TypeParameter */) + if (flags & 262144 /* TypeParameter */) return ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) return ScriptElementKind.variableElement; - if (flags & 33554432 /* Import */) + if (flags & 8388608 /* Import */) return ScriptElementKind.alias; + if (flags & 1536 /* Module */) + return ScriptElementKind.moduleElement; } return result; } @@ -21531,7 +23241,7 @@ var ts; return ScriptElementKind.localVariableElement; } if (flags & 3 /* Variable */) { - if (isFirstDeclarationOfSymbolParameter(symbol)) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { @@ -21553,7 +23263,7 @@ var ts; if (flags & 16384 /* Constructor */) return ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 1073741824 /* UnionProperty */) { + if (flags & 268435456 /* UnionProperty */) { var unionPropertyKind = ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { @@ -21562,7 +23272,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - var typeOfUnionProperty = typeInfoResolver.getNarrowedTypeOfSymbol(symbol, location); + var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { return ScriptElementKind.memberFunctionElement; } @@ -21592,29 +23302,33 @@ var ts; } function getNodeKind(node) { switch (node.kind) { - case 192 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 188 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 189 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 190 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 191 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 185 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : node.flags & 2048 /* Let */ ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 186 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 127 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 128 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 125 /* Method */: return ScriptElementKind.memberFunctionElement; - case 124 /* Property */: return ScriptElementKind.memberVariableElement; - case 131 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 130 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 129 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 126 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 122 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 196 /* EnumMember */: return ScriptElementKind.variableElement; - case 123 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 195 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 191 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 192 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 193 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 194 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 189 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : node.flags & 2048 /* Let */ ? ScriptElementKind.letElement : ScriptElementKind.variableElement; + case 190 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 130 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 131 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + return ScriptElementKind.memberFunctionElement; + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + return ScriptElementKind.memberVariableElement; + case 134 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 133 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 132 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 129 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 123 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 206 /* EnumMember */: return ScriptElementKind.variableElement; + case 124 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; } return ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 ? getNodeModifiers(symbol.declarations[0]) : ScriptElementKindModifier.none; + return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) : ScriptElementKindModifier.none; } function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location, semanticMeaning) { if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } @@ -21623,20 +23337,20 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location); var hasAddedSymbolInfo; - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 33554432 /* Import */) { + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Import */) { if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location); + var type = typeResolver.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 145 /* PropertyAccess */) { - var right = location.parent.right; - if (right === location || (right && right.kind === 120 /* Missing */)) { + if (location.parent && location.parent.kind === 149 /* PropertyAccessExpression */) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 147 /* CallExpression */ || location.kind === 148 /* NewExpression */) { + if (location.kind === 151 /* CallExpression */ || location.kind === 152 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -21648,7 +23362,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 148 /* NewExpression */ || callExpression.func.kind === 89 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 152 /* NewExpression */ || callExpression.expression.kind === 90 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -21658,15 +23372,15 @@ var ts; symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 33554432 /* Import */) { + else if (symbolFlags & 8388608 /* Import */) { symbolKind = ScriptElementKind.alias; - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.textPart(symbolKind)); + displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(87 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); } @@ -21677,16 +23391,17 @@ var ts; case ScriptElementKind.memberVariableElement: case ScriptElementKind.variableElement: case ScriptElementKind.constElement: + case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(punctuationPart(50 /* ColonToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(87 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 /* Anonymous */)) { - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -21696,21 +23411,22 @@ var ts; hasAddedSymbolInfo = true; } } - else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || (location.kind === 111 /* ConstructorKeyword */ && location.parent.kind === 126 /* Constructor */)) { + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || (location.kind === 112 /* ConstructorKeyword */ && location.parent.kind === 129 /* Constructor */)) { var signature; var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 126 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 129 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 126 /* Constructor */) { - addPrefixForAnyFunctionOrVar(type.symbol, ScriptElementKind.constructorImplementationElement); + if (functionDeclaration.kind === 129 /* Constructor */) { + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 129 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 132 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); hasAddedSymbolInfo = true; @@ -21718,107 +23434,107 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - displayParts.push(keywordPart(67 /* ClassKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(68 /* ClassKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(101 /* InterfaceKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(102 /* InterfaceKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if (symbolFlags & 2097152 /* TypeAlias */) { + if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(119 /* TypeKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(120 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(52 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, function (declaration) { return ts.isConstEnumDeclaration(declaration); })) { - displayParts.push(keywordPart(68 /* ConstKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(69 /* ConstKeyword */)); + displayParts.push(ts.spacePart()); } - displayParts.push(keywordPart(75 /* EnumKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(76 /* EnumKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(114 /* ModuleKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(115 /* ModuleKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 1048576 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart("type parameter")); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(spacePart()); - displayParts.push(keywordPart(84 /* InKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(85 /* InKeyword */)); + displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 123 /* TypeParameter */).parent; var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 130 /* ConstructSignature */) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + if (signatureDeclaration.kind === 133 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(87 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 129 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 132 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 196 /* EnumMember */) { + if (declaration.kind === 206 /* EnumMember */) { var constantValue = typeResolver.getEnumMemberValue(declaration); if (constantValue !== undefined) { - displayParts.push(spacePart()); - displayParts.push(operatorPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push(displayPart(constantValue.toString(), 7 /* numericLiteral */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(52 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), 7 /* numericLiteral */)); } } } - if (symbolFlags & 33554432 /* Import */) { + if (symbolFlags & 8388608 /* Import */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(83 /* ImportKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(84 /* ImportKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 194 /* ImportDeclaration */) { + if (declaration.kind === 197 /* ImportDeclaration */) { var importDeclaration = declaration; - if (importDeclaration.externalModuleName) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push(keywordPart(115 /* RequireKeyword */)); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(displayPart(ts.getTextOfNode(importDeclaration.externalModuleName), 8 /* stringLiteral */)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); + if (ts.isExternalModuleImportDeclaration(importDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(52 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(116 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportDeclarationExpression(importDeclaration)), 8 /* stringLiteral */)); + displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); } else { - var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); + var internalAliasSymbol = typeResolver.getSymbolAtLocation(importDeclaration.moduleReference); if (internalAliasSymbol) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(52 /* EqualsToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } } @@ -21831,19 +23547,19 @@ var ts; if (type) { addPrefixForAnyFunctionOrVar(symbol, symbolKind); if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(punctuationPart(50 /* ColonToken */)); - displayParts.push(spacePart()); - if (type.symbol && type.symbol.flags & 1048576 /* TypeParameter */) { - var typeParameterParts = mapToDisplayParts(function (writer) { + displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.spacePart()); + if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration)); + displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, type, enclosingDeclaration)); } } - else if (symbolFlags & 16 /* Function */ || symbolFlags & 8192 /* Method */ || symbolFlags & 16384 /* Constructor */ || symbolFlags & 917504 /* Signature */ || symbolFlags & 98304 /* Accessor */ || symbolKind === ScriptElementKind.memberFunctionElement) { + else if (symbolFlags & 16 /* Function */ || symbolFlags & 8192 /* Method */ || symbolFlags & 16384 /* Constructor */ || symbolFlags & 131072 /* Signature */ || symbolFlags & 98304 /* Accessor */ || symbolKind === ScriptElementKind.memberFunctionElement) { var allSignatures = type.getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -21859,38 +23575,38 @@ var ts; return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { - displayParts.push(lineBreakPart()); + displayParts.push(ts.lineBreakPart()); } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); displayParts.push.apply(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.textPart(symbolKind)); + displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } } function addSignatureDisplayParts(signature, allSignatures, flags) { - displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(operatorPart(32 /* PlusToken */)); - displayParts.push(displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); - displayParts.push(spacePart()); - displayParts.push(textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(33 /* PlusToken */)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); @@ -21904,21 +23620,21 @@ var ts; if (!node) { return undefined; } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 64 /* Identifier */: + case 149 /* PropertyAccessExpression */: case 121 /* QualifiedName */: - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - var type = typeInfoResolver.getTypeOfNode(node); + case 92 /* ThisKeyword */: + case 90 /* SuperKeyword */: + var type = typeInfoResolver.getTypeAtLocation(node); if (type) { return { kind: ScriptElementKind.unknown, kindModifiers: ScriptElementKindModifier.none, - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), - displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)), + textSpan: new TextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined }; } @@ -21929,7 +23645,7 @@ var ts; return { kind: displayPartsDocumentationsAndKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), + textSpan: new TextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, documentation: displayPartsDocumentationsAndKind.documentation }; @@ -21938,7 +23654,7 @@ var ts; function getDefinitionInfo(node, symbolKind, symbolName, containerName) { return { fileName: node.getSourceFile().filename, - textSpan: ts.TextSpan.fromBounds(node.getStart(), node.getEnd()), + textSpan: TextSpan.fromBounds(node.getStart(), node.getEnd()), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -21949,7 +23665,7 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 186 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) { + if ((selectConstructors && d.kind === 129 /* Constructor */) || (!selectConstructors && (d.kind === 190 /* FunctionDeclaration */ || d.kind === 128 /* MethodDeclaration */ || d.kind === 127 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -21966,10 +23682,10 @@ var ts; return false; } function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 111 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 112 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 188 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 191 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -21999,7 +23715,7 @@ var ts; if (referenceFile) { return [{ fileName: referenceFile.filename, - textSpan: ts.TextSpan.fromBounds(0, 0), + textSpan: TextSpan.fromBounds(0, 0), kind: ScriptElementKind.scriptElement, name: comment.filename, containerName: undefined, @@ -22008,12 +23724,12 @@ var ts; } return undefined; } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { return undefined; } var result = []; - if (node.parent.kind === 144 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 205 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var shorthandDeclarations = shorthandSymbol.getDeclarations(); var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver); @@ -22044,98 +23760,98 @@ var ts; if (!node) { return undefined; } - if (node.kind === 63 /* Identifier */ || node.kind === 91 /* ThisKeyword */ || node.kind === 89 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { + if (node.kind === 64 /* Identifier */ || node.kind === 92 /* ThisKeyword */ || node.kind === 90 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return getReferencesForNode(node, [sourceFile], false, false); } switch (node.kind) { - case 82 /* IfKeyword */: - case 74 /* ElseKeyword */: - if (hasKind(node.parent, 166 /* IfStatement */)) { + case 83 /* IfKeyword */: + case 75 /* ElseKeyword */: + if (hasKind(node.parent, 173 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 88 /* ReturnKeyword */: - if (hasKind(node.parent, 173 /* ReturnStatement */)) { + case 89 /* ReturnKeyword */: + if (hasKind(node.parent, 180 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 92 /* ThrowKeyword */: - if (hasKind(node.parent, 179 /* ThrowStatement */)) { + case 93 /* ThrowKeyword */: + if (hasKind(node.parent, 184 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 94 /* TryKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: - if (hasKind(parent(parent(node)), 180 /* TryStatement */)) { + case 95 /* TryKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: + if (hasKind(parent(parent(node)), 185 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 90 /* SwitchKeyword */: - if (hasKind(node.parent, 175 /* SwitchStatement */)) { + case 91 /* SwitchKeyword */: + if (hasKind(node.parent, 182 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 65 /* CaseKeyword */: - case 71 /* DefaultKeyword */: - if (hasKind(parent(parent(node)), 175 /* SwitchStatement */)) { + case 66 /* CaseKeyword */: + case 72 /* DefaultKeyword */: + if (hasKind(parent(parent(node)), 182 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent); } break; - case 64 /* BreakKeyword */: - case 69 /* ContinueKeyword */: - if (hasKind(node.parent, 172 /* BreakStatement */) || hasKind(node.parent, 171 /* ContinueStatement */)) { + case 65 /* BreakKeyword */: + case 70 /* ContinueKeyword */: + if (hasKind(node.parent, 179 /* BreakStatement */) || hasKind(node.parent, 178 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 80 /* ForKeyword */: - if (hasKind(node.parent, 169 /* ForStatement */) || hasKind(node.parent, 170 /* ForInStatement */)) { + case 81 /* ForKeyword */: + if (hasKind(node.parent, 176 /* ForStatement */) || hasKind(node.parent, 177 /* ForInStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 98 /* WhileKeyword */: - case 73 /* DoKeyword */: - if (hasKind(node.parent, 168 /* WhileStatement */) || hasKind(node.parent, 167 /* DoStatement */)) { + case 99 /* WhileKeyword */: + case 74 /* DoKeyword */: + if (hasKind(node.parent, 175 /* WhileStatement */) || hasKind(node.parent, 174 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 111 /* ConstructorKeyword */: - if (hasKind(node.parent, 126 /* Constructor */)) { + case 112 /* ConstructorKeyword */: + if (hasKind(node.parent, 129 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 113 /* GetKeyword */: - case 117 /* SetKeyword */: - if (hasKind(node.parent, 127 /* GetAccessor */) || hasKind(node.parent, 128 /* SetAccessor */)) { + case 114 /* GetKeyword */: + case 118 /* SetKeyword */: + if (hasKind(node.parent, 130 /* GetAccessor */) || hasKind(node.parent, 131 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: - if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 163 /* VariableStatement */)) { + if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 170 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 166 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 173 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 82 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 83 /* IfKeyword */); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 74 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 75 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 166 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 173 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 74 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 75 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldHighlightNextKeyword = true; @@ -22148,7 +23864,7 @@ var ts; if (shouldHighlightNextKeyword) { result.push({ fileName: filename, - textSpan: ts.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), + textSpan: TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); i++; @@ -22161,15 +23877,15 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 187 /* FunctionBlock */))) { + if (!(func && hasKind(func.body, 169 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 89 /* ReturnKeyword */); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 93 /* ThrowKeyword */); }); return ts.map(keywords, getReferenceEntryFromNode); } @@ -22180,11 +23896,11 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 93 /* ThrowKeyword */); }); - if (owner.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 89 /* ReturnKeyword */); }); } return ts.map(keywords, getReferenceEntryFromNode); @@ -22194,13 +23910,13 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 179 /* ThrowStatement */) { + if (node.kind === 184 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 180 /* TryStatement */) { + else if (node.kind === 185 /* TryStatement */) { var tryStatement = node; - if (tryStatement.catchBlock) { - aggregate(tryStatement.catchBlock); + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { aggregate(tryStatement.tryBlock); @@ -22219,12 +23935,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (parent.kind === 187 /* FunctionBlock */ || parent.kind === 197 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 207 /* SourceFile */) { return parent; } - if (parent.kind === 180 /* TryStatement */) { + if (parent.kind === 185 /* TryStatement */) { var tryStatement = parent; - if (tryStatement.tryBlock === child && tryStatement.catchBlock) { + if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } @@ -22234,22 +23950,22 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 94 /* TryKeyword */); - if (tryStatement.catchBlock) { - pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), 66 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 95 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 67 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 79 /* FinallyKeyword */); + pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 80 /* FinallyKeyword */); } return ts.map(keywords, getReferenceEntryFromNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 80 /* ForKeyword */, 98 /* WhileKeyword */, 73 /* DoKeyword */)) { - if (loopNode.kind === 167 /* DoStatement */) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 81 /* ForKeyword */, 99 /* WhileKeyword */, 74 /* DoKeyword */)) { + if (loopNode.kind === 174 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 98 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 99 /* WhileKeyword */)) { break; } } @@ -22258,20 +23974,20 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 64 /* BreakKeyword */, 69 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 65 /* BreakKeyword */, 70 /* ContinueKeyword */); } }); return ts.map(keywords, getReferenceEntryFromNode); } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 90 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 91 /* SwitchKeyword */); ts.forEach(switchStatement.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 65 /* CaseKeyword */, 71 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 66 /* CaseKeyword */, 72 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 64 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 65 /* BreakKeyword */); } }); }); @@ -22281,12 +23997,12 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 174 /* DoStatement */: + case 175 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -22297,7 +24013,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 172 /* BreakStatement */ || node.kind === 171 /* ContinueStatement */) { + if (node.kind === 179 /* BreakStatement */ || node.kind === 178 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isAnyFunction(node)) { @@ -22313,14 +24029,14 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node = statement.parent; node; node = node.parent) { switch (node.kind) { - case 175 /* SwitchStatement */: - if (statement.kind === 171 /* ContinueStatement */) { + case 182 /* SwitchStatement */: + if (statement.kind === 178 /* ContinueStatement */) { continue; } - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 168 /* WhileStatement */: - case 167 /* DoStatement */: + case 176 /* ForStatement */: + case 177 /* ForInStatement */: + case 175 /* WhileStatement */: + case 174 /* DoStatement */: if (!statement.label || isLabeledBy(node, statement.label.text)) { return node; } @@ -22339,56 +24055,59 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 111 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 112 /* ConstructorKeyword */); }); }); return ts.map(keywords, getReferenceEntryFromNode); } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 127 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 128 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 130 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 131 /* SetAccessor */); return ts.map(keywords, getReferenceEntryFromNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 113 /* GetKeyword */, 117 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 114 /* GetKeyword */, 118 /* SetKeyword */); }); } } } function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (declaration.flags & 112 /* AccessibilityModifier */) { - if (!(container.kind === 188 /* ClassDeclaration */ || (declaration.kind === 123 /* Parameter */ && hasKind(container, 126 /* Constructor */)))) { + if (!(container.kind === 191 /* ClassDeclaration */ || (declaration.kind === 124 /* Parameter */ && hasKind(container, 129 /* Constructor */)))) { return undefined; } } else if (declaration.flags & 128 /* Static */) { - if (container.kind !== 188 /* ClassDeclaration */) { + if (container.kind !== 191 /* ClassDeclaration */) { return undefined; } } else if (declaration.flags & (1 /* Export */ | 2 /* Ambient */)) { - if (!(container.kind === 193 /* ModuleBlock */ || container.kind === 197 /* SourceFile */)) { + if (!(container.kind === 196 /* ModuleBlock */ || container.kind === 207 /* SourceFile */)) { return undefined; } } + else { + return undefined; + } var keywords = []; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: + case 196 /* ModuleBlock */: + case 207 /* SourceFile */: nodes = container.statements; break; - case 126 /* Constructor */: + case 129 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: nodes = container.members; if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 126 /* Constructor */ && member; + return member.kind === 129 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -22399,24 +24118,24 @@ var ts; ts.Debug.fail("Invalid container kind."); } ts.forEach(nodes, function (node) { - if (node.flags & modifierFlag) { - ts.forEach(node.getChildren(), function (child) { return pushKeywordIf(keywords, child, modifier); }); + if (node.modifiers && node.flags & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); } }); return ts.map(keywords, getReferenceEntryFromNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 106 /* PublicKeyword */: + case 107 /* PublicKeyword */: return 16 /* Public */; - case 104 /* PrivateKeyword */: + case 105 /* PrivateKeyword */: return 32 /* Private */; - case 105 /* ProtectedKeyword */: + case 106 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* StaticKeyword */: + case 108 /* StaticKeyword */: return 128 /* Static */; - case 76 /* ExportKeyword */: + case 77 /* ExportKeyword */: return 1 /* Export */; - case 112 /* DeclareKeyword */: + case 113 /* DeclareKeyword */: return 2 /* Ambient */; default: ts.Debug.fail(); @@ -22455,10 +24174,10 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 63 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { + if (node.kind !== 64 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 6 /* NumericLiteral */ || node.kind === 7 /* StringLiteral */); + ts.Debug.assert(node.kind === 64 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); return getReferencesForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencesForNode(node, sourceFiles, findInStrings, findInComments) { @@ -22471,13 +24190,13 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 91 /* ThisKeyword */) { + if (node.kind === 92 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 89 /* SuperKeyword */) { + if (node.kind === 90 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { return [getReferenceEntryFromNode(node)]; } @@ -22509,7 +24228,7 @@ var ts; return stripQuotes(name); } function getInternedName(symbol, declarations) { - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 152 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 156 /* FunctionExpression */ ? d : undefined; }); if (functionExpression && functionExpression.name) { var name = functionExpression.name.text; } @@ -22530,7 +24249,7 @@ var ts; if (symbol.getFlags() && (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 188 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 191 /* ClassDeclaration */); } } if (symbol.parent) { @@ -22547,7 +24266,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 207 /* SourceFile */ && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -22596,14 +24315,14 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 63 /* Identifier */: + case 64 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 7 /* StringLiteral */: + case 8 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return node.getWidth() === searchSymbolName.length + 2; } break; - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -22625,7 +24344,7 @@ var ts; if ((findInStrings && isInString(position)) || (findInComments && isInComment(position))) { result.push({ fileName: sourceFile.filename, - textSpan: new ts.TextSpan(position, searchText.length), + textSpan: new TextSpan(position, searchText.length), isWriteAccess: false }); } @@ -22634,14 +24353,14 @@ var ts; if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { return; } - var referenceSymbol = typeInfoResolver.getSymbolInfo(referenceLocation); + var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation); if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); if (isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation)) { result.push(getReferenceEntryFromNode(referenceLocation)); } - else if (!(referenceSymbol.flags & 268435456 /* Transient */) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { + else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { result.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } @@ -22649,7 +24368,7 @@ var ts; } function isInString(position) { var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 7 /* StringLiteral */ && position > token.getStart(); + return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); } function isInComment(position) { var token = ts.getTokenAtPosition(sourceFile, position); @@ -22674,11 +24393,13 @@ var ts; } var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -22691,7 +24412,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 89 /* SuperKeyword */) { + if (!node || node.kind !== 90 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node); @@ -22705,26 +24426,31 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 197 /* SourceFile */: + case 207 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: break; default: return undefined; } var result = []; - if (searchSpaceNode.kind === 197 /* SourceFile */) { + if (searchSpaceNode.kind === 207 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, result); @@ -22740,24 +24466,30 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 91 /* ThisKeyword */) { + if (!node || node.kind !== 92 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 188 /* ClassDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 191 /* ClassDeclaration */: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 197 /* SourceFile */: - if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) { + case 207 /* SourceFile */: + if (container.kind === 207 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -22789,19 +24521,19 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 188 /* ClassDeclaration */) { - getPropertySymbolFromTypeReference(declaration.baseType); - ts.forEach(declaration.implementedTypes, getPropertySymbolFromTypeReference); + if (declaration.kind === 191 /* ClassDeclaration */) { + getPropertySymbolFromTypeReference(ts.getClassBaseTypeNode(declaration)); + ts.forEach(ts.getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 189 /* InterfaceDeclaration */) { - ts.forEach(declaration.baseTypes, getPropertySymbolFromTypeReference); + else if (declaration.kind === 192 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); } return; function getPropertySymbolFromTypeReference(typeReference) { if (typeReference) { - var type = typeInfoResolver.getTypeOfNode(typeReference); + var type = typeInfoResolver.getTypeAtLocation(typeReference); if (type) { var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName); if (propertySymbol) { @@ -22883,28 +24615,28 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 7 /* StringLiteral */) { + if (node.kind === 8 /* StringLiteral */) { start += 1; end -= 1; } return { fileName: node.getSourceFile().filename, - textSpan: ts.TextSpan.fromBounds(start, end), + textSpan: TextSpan.fromBounds(start, end), isWriteAccess: isWriteAccess(node) }; } function isWriteAccess(node) { - if (node.kind === 63 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + if (node.kind === 64 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 155 /* PostfixOperator */ || parent.kind === 154 /* PrefixOperator */) { + if (parent.kind === 162 /* PostfixUnaryExpression */ || parent.kind === 161 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 156 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 163 /* BinaryExpression */ && parent.left === node) { var operator = parent.operator; - return 51 /* FirstAssignment */ <= operator && operator <= 62 /* LastAssignment */; + return 52 /* FirstAssignment */ <= operator && operator <= 63 /* LastAssignment */; } } return false; @@ -22927,10 +24659,10 @@ var ts; items.push({ name: name, kind: getNodeKind(declaration), - kindModifiers: getNodeModifiers(declaration), + kindModifiers: ts.getNodeModifiers(declaration), matchKind: MatchKind[matchKind], fileName: filename, - textSpan: ts.TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? getNodeKind(container) : "" }); @@ -22975,70 +24707,53 @@ var ts; function getEmitOutput(filename) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); - var compilerOptions = program.getCompilerOptions(); - var targetSourceFile = program.getSourceFile(filename); - var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions); - var emitOutput = { - outputFiles: [], - emitOutputStatus: undefined - }; + var sourceFile = getSourceFile(filename); + var outputFiles = []; function getEmitOutputWriter(filename, data, writeByteOrderMark) { - emitOutput.outputFiles.push({ + outputFiles.push({ name: filename, writeByteOrderMark: writeByteOrderMark, text: data }); } writer = getEmitOutputWriter; - var containSyntacticErrors = false; - if (shouldEmitToOwnFile) { - containSyntacticErrors = containErrors(program.getDiagnostics(targetSourceFile)); - } - else { - containSyntacticErrors = ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - return containErrors(program.getDiagnostics(sourceFile)); - } - return false; - }); - } - if (containSyntacticErrors) { - emitOutput.emitOutputStatus = 1 /* AllOutputGenerationSkipped */; - writer = undefined; - return emitOutput; - } - var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile); - emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus; + var emitOutput = getFullTypeCheckChecker().emitFiles(sourceFile); writer = undefined; - return emitOutput; + return { + outputFiles: outputFiles, + emitOutputStatus: emitOutput.emitResultStatus + }; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 123 /* Parameter */: - case 185 /* VariableDeclaration */: - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 182 /* CatchBlock */: + case 124 /* Parameter */: + case 189 /* VariableDeclaration */: + case 146 /* BindingElement */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: + case 204 /* PropertyAssignment */: + case 205 /* ShorthandPropertyAssignment */: + case 206 /* EnumMember */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 129 /* Constructor */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 190 /* FunctionDeclaration */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: + case 203 /* CatchClause */: return 1 /* Value */; - case 122 /* TypeParameter */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 136 /* TypeLiteral */: + case 123 /* TypeParameter */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: + case 139 /* TypeLiteral */: return 2 /* Type */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 192 /* ModuleDeclaration */: - if (node.name.kind === 7 /* StringLiteral */) { + case 195 /* ModuleDeclaration */: + if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -23047,9 +24762,9 @@ var ts; else { return 4 /* Namespace */; } - case 194 /* ImportDeclaration */: + case 197 /* ImportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - case 197 /* SourceFile */: + case 207 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } ts.Debug.fail("Unknown declaration type"); @@ -23058,7 +24773,7 @@ var ts; if (isRightSideOfQualifiedName(node)) { node = node.parent; } - return node.parent.kind === 132 /* TypeReference */; + return node.parent.kind === 135 /* TypeReference */; } function isNamespaceReference(node) { var root = node; @@ -23068,23 +24783,23 @@ var ts; root = root.parent; isLastClause = root.right === node; } - return root.parent.kind === 132 /* TypeReference */ && !isLastClause; + return root.parent.kind === 135 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 194 /* ImportDeclaration */ && node.parent.entityName === node; + return ts.isInternalModuleImportDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImport(node) { - ts.Debug.assert(node.kind === 63 /* Identifier */); - if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 194 /* ImportDeclaration */) { + ts.Debug.assert(node.kind === 64 /* Identifier */); + if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 197 /* ImportDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 198 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -23121,15 +24836,15 @@ var ts; return; } switch (node.kind) { - case 145 /* PropertyAccess */: + case 149 /* PropertyAccessExpression */: case 121 /* QualifiedName */: - case 7 /* StringLiteral */: - case 78 /* FalseKeyword */: - case 93 /* TrueKeyword */: - case 87 /* NullKeyword */: - case 89 /* SuperKeyword */: - case 91 /* ThisKeyword */: - case 63 /* Identifier */: + case 8 /* StringLiteral */: + case 79 /* FalseKeyword */: + case 94 /* TrueKeyword */: + case 88 /* NullKeyword */: + case 90 /* SuperKeyword */: + case 92 /* ThisKeyword */: + case 64 /* Identifier */: break; default: return; @@ -23140,7 +24855,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 192 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + if (nodeForStartPos.parent.parent.kind === 195 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } else { @@ -23151,7 +24866,7 @@ var ts; break; } } - return ts.TextSpan.fromBounds(nodeForStartPos.getStart(), node.getEnd()); + return TextSpan.fromBounds(nodeForStartPos.getStart(), node.getEnd()); } function getBreakpointStatementAtPosition(filename, position) { filename = ts.normalizeSlashes(filename); @@ -23176,11 +24891,14 @@ var ts; else if (flags & 384 /* Enum */) { return ClassificationTypeNames.enumName; } + else if (flags & 524288 /* TypeAlias */) { + return ClassificationTypeNames.typeAlias; + } else if (meaningAtPosition & 2 /* Type */) { if (flags & 64 /* Interface */) { return ClassificationTypeNames.interfaceName; } - else if (flags & 1048576 /* TypeParameter */) { + else if (flags & 262144 /* TypeParameter */) { return ClassificationTypeNames.typeParameterName; } } @@ -23192,19 +24910,19 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 195 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; }); } } function processNode(node) { if (node && span.intersectsWith(node.getStart(), node.getWidth())) { - if (node.kind === 63 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeInfoResolver.getSymbolInfo(node); + if (node.kind === 64 /* Identifier */ && node.getWidth() > 0) { + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { result.push({ - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), + textSpan: new TextSpan(node.getStart(), node.getWidth()), classificationType: type }); } @@ -23224,7 +24942,7 @@ var ts; var width = comment.end - comment.pos; if (span.intersectsWith(comment.pos, width)) { result.push({ - textSpan: new ts.TextSpan(comment.pos, width), + textSpan: new TextSpan(comment.pos, width), classificationType: ClassificationTypeNames.comment }); } @@ -23235,7 +24953,7 @@ var ts; var type = classifyTokenType(token); if (type) { result.push({ - textSpan: new ts.TextSpan(token.getStart(), token.getWidth()), + textSpan: new TextSpan(token.getStart(), token.getWidth()), classificationType: type }); } @@ -23247,54 +24965,54 @@ var ts; if (ts.isKeyword(tokenKind)) { return ClassificationTypeNames.keyword; } - if (tokenKind === 23 /* LessThanToken */ || tokenKind === 24 /* GreaterThanToken */) { + if (tokenKind === 24 /* LessThanToken */ || tokenKind === 25 /* GreaterThanToken */) { if (ts.getTypeArgumentOrTypeParameterList(token.parent)) { return ClassificationTypeNames.punctuation; } } if (ts.isPunctuation(token.kind)) { - if (token.parent.kind === 156 /* BinaryExpression */ || token.parent.kind === 185 /* VariableDeclaration */ || token.parent.kind === 154 /* PrefixOperator */ || token.parent.kind === 155 /* PostfixOperator */ || token.parent.kind === 157 /* ConditionalExpression */) { + if (token.parent.kind === 163 /* BinaryExpression */ || token.parent.kind === 189 /* VariableDeclaration */ || token.parent.kind === 161 /* PrefixUnaryExpression */ || token.parent.kind === 162 /* PostfixUnaryExpression */ || token.parent.kind === 164 /* ConditionalExpression */) { return ClassificationTypeNames.operator; } else { return ClassificationTypeNames.punctuation; } } - else if (tokenKind === 6 /* NumericLiteral */) { + else if (tokenKind === 7 /* NumericLiteral */) { return ClassificationTypeNames.numericLiteral; } - else if (tokenKind === 7 /* StringLiteral */) { + else if (tokenKind === 8 /* StringLiteral */) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 8 /* RegularExpressionLiteral */) { + else if (tokenKind === 9 /* RegularExpressionLiteral */) { return ClassificationTypeNames.stringLiteral; } else if (ts.isTemplateLiteralKind(tokenKind)) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 63 /* Identifier */) { + else if (tokenKind === 64 /* Identifier */) { switch (token.parent.kind) { - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.className; } return; - case 122 /* TypeParameter */: + case 123 /* TypeParameter */: if (token.parent.name === token) { return ClassificationTypeNames.typeParameterName; } return; - case 189 /* InterfaceDeclaration */: + case 192 /* InterfaceDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -23337,8 +25055,8 @@ var ts; 33; var current = childNodes[i]; if (current.kind === matchKind) { - var range1 = new ts.TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = new ts.TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + var range1 = new TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = new TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); if (range1.start() < range2.start()) { result.push(range1, range2); } @@ -23353,14 +25071,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 13 /* OpenBraceToken */: return 14 /* CloseBraceToken */; - case 15 /* OpenParenToken */: return 16 /* CloseParenToken */; - case 17 /* OpenBracketToken */: return 18 /* CloseBracketToken */; - case 23 /* LessThanToken */: return 24 /* GreaterThanToken */; - case 14 /* CloseBraceToken */: return 13 /* OpenBraceToken */; - case 16 /* CloseParenToken */: return 15 /* OpenParenToken */; - case 18 /* CloseBracketToken */: return 17 /* OpenBracketToken */; - case 24 /* GreaterThanToken */: return 23 /* LessThanToken */; + case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; + case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; + case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; + case 24 /* LessThanToken */: return 25 /* GreaterThanToken */; + case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; + case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; + case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; + case 25 /* GreaterThanToken */: return 24 /* LessThanToken */; } return undefined; } @@ -23454,17 +25172,6 @@ var ts; var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; return new RegExp(regExpString, "gim"); } - function getContainingComment(comments, position) { - if (comments) { - for (var i = 0, n = comments.length; i < n; i++) { - var comment = comments[i]; - if (comment.pos <= position && position < comment.end) { - return comment; - } - } - } - return undefined; - } function isLetterOrDigit(char) { return (char >= 97 /* a */ && char <= 122 /* z */) || (char >= 65 /* A */ && char <= 90 /* Z */) || (char >= 48 /* _0 */ && char <= 57 /* _9 */); } @@ -23474,12 +25181,12 @@ var ts; fileName = ts.normalizeSlashes(fileName); var sourceFile = getSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 63 /* Identifier */) { - var symbol = typeInfoResolver.getSymbolInfo(node); + if (node && node.kind === 64 /* Identifier */) { + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) { var kind = getSymbolKind(symbol, typeInfoResolver); if (kind) { - return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), new ts.TextSpan(node.getStart(), node.getWidth())); + return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), new TextSpan(node.getStart(), node.getWidth())); } } } @@ -23543,30 +25250,30 @@ var ts; function createClassifier(host) { var scanner = ts.createScanner(2 /* Latest */, false); var noRegexTable = []; - noRegexTable[63 /* Identifier */] = true; - noRegexTable[7 /* StringLiteral */] = true; - noRegexTable[6 /* NumericLiteral */] = true; - noRegexTable[8 /* RegularExpressionLiteral */] = true; - noRegexTable[91 /* ThisKeyword */] = true; - noRegexTable[37 /* PlusPlusToken */] = true; - noRegexTable[38 /* MinusMinusToken */] = true; - noRegexTable[16 /* CloseParenToken */] = true; - noRegexTable[18 /* CloseBracketToken */] = true; - noRegexTable[14 /* CloseBraceToken */] = true; - noRegexTable[93 /* TrueKeyword */] = true; - noRegexTable[78 /* FalseKeyword */] = true; + noRegexTable[64 /* Identifier */] = true; + noRegexTable[8 /* StringLiteral */] = true; + noRegexTable[7 /* NumericLiteral */] = true; + noRegexTable[9 /* RegularExpressionLiteral */] = true; + noRegexTable[92 /* ThisKeyword */] = true; + noRegexTable[38 /* PlusPlusToken */] = true; + noRegexTable[39 /* MinusMinusToken */] = true; + noRegexTable[17 /* CloseParenToken */] = true; + noRegexTable[19 /* CloseBracketToken */] = true; + noRegexTable[15 /* CloseBraceToken */] = true; + noRegexTable[94 /* TrueKeyword */] = true; + noRegexTable[79 /* FalseKeyword */] = true; function isAccessibilityModifier(kind) { switch (kind) { - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: + case 107 /* PublicKeyword */: + case 105 /* PrivateKeyword */: + case 106 /* ProtectedKeyword */: return true; } return false; } function canFollow(keyword1, keyword2) { if (isAccessibilityModifier(keyword1)) { - if (keyword2 === 113 /* GetKeyword */ || keyword2 === 117 /* SetKeyword */ || keyword2 === 111 /* ConstructorKeyword */ || keyword2 === 107 /* StaticKeyword */) { + if (keyword2 === 114 /* GetKeyword */ || keyword2 === 118 /* SetKeyword */ || keyword2 === 112 /* ConstructorKeyword */ || keyword2 === 108 /* StaticKeyword */) { return true; } return false; @@ -23600,26 +25307,26 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 8 /* RegularExpressionLiteral */) { - token = 8 /* RegularExpressionLiteral */; + if ((token === 36 /* SlashToken */ || token === 56 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + token = 9 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 19 /* DotToken */ && isKeyword(token)) { - token = 63 /* Identifier */; + else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { + token = 64 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 63 /* Identifier */; + token = 64 /* Identifier */; } - else if (lastNonTriviaToken === 63 /* Identifier */ && token === 23 /* LessThanToken */) { + else if (lastNonTriviaToken === 64 /* Identifier */ && token === 24 /* LessThanToken */) { angleBracketStack++; } - else if (token === 24 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 25 /* GreaterThanToken */ && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 109 /* AnyKeyword */ || token === 118 /* StringKeyword */ || token === 116 /* NumberKeyword */ || token === 110 /* BooleanKeyword */) { + else if (token === 110 /* AnyKeyword */ || token === 119 /* StringKeyword */ || token === 117 /* NumberKeyword */ || token === 111 /* BooleanKeyword */) { if (angleBracketStack > 0 && !classifyKeywordsInGenerics) { - token = 63 /* Identifier */; + token = 64 /* Identifier */; } } lastNonTriviaToken = token; @@ -23632,16 +25339,22 @@ var ts; var end = scanner.getTextPos(); addResult(end - start, classFromKind(token)); if (end >= text.length) { - if (token === 7 /* StringLiteral */) { + if (token === 8 /* StringLiteral */) { var tokenText = scanner.getTokenText(); - if (tokenText.length > 0 && tokenText.charCodeAt(tokenText.length - 1) === 92 /* backslash */) { - var quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + numBackslashes++; + } + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.finalLexState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + } } } else if (token === 3 /* MultiLineCommentTrivia */) { - var tokenText = scanner.getTokenText(); - if (!(tokenText.length > 3 && tokenText.charCodeAt(tokenText.length - 2) === 42 /* asterisk */ && tokenText.charCodeAt(tokenText.length - 1) === 47 /* slash */)) { + if (scanner.isUnterminated()) { result.finalLexState = 1 /* InMultiLineCommentTrivia */; } } @@ -23658,61 +25371,61 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 39 /* LessThanLessThanToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: - case 85 /* InstanceOfKeyword */: - case 84 /* InKeyword */: - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - case 42 /* AmpersandToken */: - case 44 /* CaretToken */: - case 43 /* BarToken */: - case 47 /* AmpersandAmpersandToken */: - case 48 /* BarBarToken */: - case 61 /* BarEqualsToken */: - case 60 /* AmpersandEqualsToken */: - case 62 /* CaretEqualsToken */: - case 57 /* LessThanLessThanEqualsToken */: - case 58 /* GreaterThanGreaterThanEqualsToken */: - case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 52 /* PlusEqualsToken */: - case 53 /* MinusEqualsToken */: - case 54 /* AsteriskEqualsToken */: - case 55 /* SlashEqualsToken */: - case 56 /* PercentEqualsToken */: - case 51 /* EqualsToken */: - case 22 /* CommaToken */: + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 40 /* LessThanLessThanToken */: + case 41 /* GreaterThanGreaterThanToken */: + case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 24 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 26 /* LessThanEqualsToken */: + case 27 /* GreaterThanEqualsToken */: + case 86 /* InstanceOfKeyword */: + case 85 /* InKeyword */: + case 28 /* EqualsEqualsToken */: + case 29 /* ExclamationEqualsToken */: + case 30 /* EqualsEqualsEqualsToken */: + case 31 /* ExclamationEqualsEqualsToken */: + case 43 /* AmpersandToken */: + case 45 /* CaretToken */: + case 44 /* BarToken */: + case 48 /* AmpersandAmpersandToken */: + case 49 /* BarBarToken */: + case 62 /* BarEqualsToken */: + case 61 /* AmpersandEqualsToken */: + case 63 /* CaretEqualsToken */: + case 58 /* LessThanLessThanEqualsToken */: + case 59 /* GreaterThanGreaterThanEqualsToken */: + case 60 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 53 /* PlusEqualsToken */: + case 54 /* MinusEqualsToken */: + case 55 /* AsteriskEqualsToken */: + case 56 /* SlashEqualsToken */: + case 57 /* PercentEqualsToken */: + case 52 /* EqualsToken */: + case 23 /* CommaToken */: return true; default: return false; } } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: + case 33 /* PlusToken */: + case 34 /* MinusToken */: + case 47 /* TildeToken */: + case 46 /* ExclamationToken */: + case 38 /* PlusPlusToken */: + case 39 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 64 /* FirstKeyword */ && token <= 119 /* LastKeyword */; + return token >= 65 /* FirstKeyword */ && token <= 120 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -23721,22 +25434,23 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 2 /* Operator */; } - else if (token >= 13 /* FirstPunctuation */ && token <= 62 /* LastPunctuation */) { + else if (token >= 14 /* FirstPunctuation */ && token <= 63 /* LastPunctuation */) { return 0 /* Punctuation */; } switch (token) { - case 6 /* NumericLiteral */: + case 7 /* NumericLiteral */: return 6 /* NumberLiteral */; - case 7 /* StringLiteral */: + case 8 /* StringLiteral */: return 7 /* StringLiteral */; - case 8 /* RegularExpressionLiteral */: + case 9 /* RegularExpressionLiteral */: return 8 /* RegExpLiteral */; + case 6 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 3 /* Comment */; case 5 /* WhitespaceTrivia */: return 4 /* Whitespace */; - case 63 /* Identifier */: + case 64 /* Identifier */: default: return 5 /* Identifier */; } @@ -23749,7 +25463,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 197 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 207 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -23803,122 +25517,126 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 174 /* DoStatement */) { return spanInPreviousNode(node); } - if (node.parent.kind === 169 /* ForStatement */) { + if (node.parent.kind === 176 /* ForStatement */) { return textSpan(node); } - if (node.parent.kind === 156 /* BinaryExpression */ && node.parent.operator === 22 /* CommaToken */) { + if (node.parent.kind === 163 /* BinaryExpression */ && node.parent.operator === 23 /* CommaToken */) { return textSpan(node); } - if (node.parent.kind == 153 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind == 157 /* ArrowFunction */ && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 163 /* VariableStatement */: + case 170 /* VariableStatement */: return spanInVariableDeclaration(node.declarations[0]); - case 185 /* VariableDeclaration */: - case 124 /* Property */: + case 189 /* VariableDeclaration */: + case 126 /* PropertyDeclaration */: + case 125 /* PropertySignature */: return spanInVariableDeclaration(node); - case 123 /* Parameter */: + case 124 /* Parameter */: return spanInParameterDeclaration(node); - case 186 /* FunctionDeclaration */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 190 /* FunctionDeclaration */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 156 /* FunctionExpression */: + case 157 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 187 /* FunctionBlock */: - return spanInFunctionBlock(node); - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + case 169 /* Block */: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); + } + case 186 /* TryBlock */: + case 187 /* FinallyBlock */: + case 196 /* ModuleBlock */: return spanInBlock(node); - case 165 /* ExpressionStatement */: + case 203 /* CatchClause */: + return spanInBlock(node.block); + case 172 /* ExpressionStatement */: return textSpan(node.expression); - case 173 /* ReturnStatement */: + case 180 /* ReturnStatement */: return textSpan(node.getChildAt(0), node.expression); - case 168 /* WhileStatement */: + case 175 /* WhileStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 167 /* DoStatement */: + case 174 /* DoStatement */: return spanInNode(node.statement); - case 184 /* DebuggerStatement */: + case 188 /* DebuggerStatement */: return textSpan(node.getChildAt(0)); - case 166 /* IfStatement */: + case 173 /* IfStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 178 /* LabeledStatement */: + case 183 /* LabeledStatement */: return spanInNode(node.statement); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + case 179 /* BreakStatement */: + case 178 /* ContinueStatement */: return textSpan(node.getChildAt(0), node.label); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return spanInForStatement(node); - case 170 /* ForInStatement */: + case 177 /* ForInStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 200 /* CaseClause */: + case 201 /* DefaultClause */: return spanInNode(node.statements[0]); - case 180 /* TryStatement */: + case 185 /* TryStatement */: return spanInBlock(node.tryBlock); - case 179 /* ThrowStatement */: + case 184 /* ThrowStatement */: return textSpan(node, node.expression); - case 195 /* ExportAssignment */: + case 198 /* ExportAssignment */: return textSpan(node, node.exportName); - case 194 /* ImportDeclaration */: - return textSpan(node, node.entityName || node.externalModuleName); - case 192 /* ModuleDeclaration */: + case 197 /* ImportDeclaration */: + return textSpan(node, node.moduleReference); + case 195 /* ModuleDeclaration */: if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 191 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 206 /* EnumMember */: + case 151 /* CallExpression */: + case 152 /* NewExpression */: return textSpan(node); - case 174 /* WithStatement */: + case 181 /* WithStatement */: return spanInNode(node.statement); - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: + case 192 /* InterfaceDeclaration */: + case 193 /* TypeAliasDeclaration */: return undefined; - case 21 /* SemicolonToken */: + case 22 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 22 /* CommaToken */: + case 23 /* CommaToken */: return spanInPreviousNode(node); - case 13 /* OpenBraceToken */: + case 14 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 14 /* CloseBraceToken */: + case 15 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 15 /* OpenParenToken */: + case 16 /* OpenParenToken */: return spanInOpenParenToken(node); - case 16 /* CloseParenToken */: + case 17 /* CloseParenToken */: return spanInCloseParenToken(node); - case 50 /* ColonToken */: + case 51 /* ColonToken */: return spanInColonToken(node); - case 24 /* GreaterThanToken */: - case 23 /* LessThanToken */: + case 25 /* GreaterThanToken */: + case 24 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); - case 98 /* WhileKeyword */: + case 99 /* WhileKeyword */: return spanInWhileKeyword(node); - case 74 /* ElseKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: + case 75 /* ElseKeyword */: + case 67 /* CatchKeyword */: + case 80 /* FinallyKeyword */: return spanInNextNode(node); default: - if (node.parent.kind === 143 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 204 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 150 /* TypeAssertion */ && node.parent.type === node) { - return spanInNode(node.parent.operand); + if (node.parent.kind === 154 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNode(node.parent.expression); } if (ts.isAnyFunction(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); @@ -23927,11 +25645,11 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.kind === 170 /* ForInStatement */) { + if (variableDeclaration.parent.kind === 177 /* ForInStatement */) { return spanInNode(variableDeclaration.parent); } - var isParentVariableStatement = variableDeclaration.parent.kind === 163 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.kind === 169 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.kind === 170 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.kind === 176 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.declarations : isDeclarationOfForStatement ? variableDeclaration.parent.declarations : undefined; if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { @@ -23953,7 +25671,7 @@ var ts; } } function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || !!(parameter.flags & 8 /* Rest */) || !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -23971,7 +25689,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 188 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */); + return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 191 /* ClassDeclaration */ && functionDeclaration.kind !== 129 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -23991,15 +25709,15 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 192 /* ModuleDeclaration */: + case 195 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - case 168 /* WhileStatement */: - case 166 /* IfStatement */: - case 170 /* ForInStatement */: + case 175 /* WhileStatement */: + case 173 /* IfStatement */: + case 177 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 169 /* ForStatement */: + case 176 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); @@ -24020,34 +25738,36 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 191 /* EnumDeclaration */: + case 194 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 188 /* ClassDeclaration */: + case 191 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: return spanInNodeIfStartsOnSameLine(node.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 193 /* ModuleBlock */: + case 196 /* ModuleBlock */: if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 187 /* FunctionBlock */: - case 191 /* EnumDeclaration */: - case 188 /* ClassDeclaration */: + case 194 /* EnumDeclaration */: + case 191 /* ClassDeclaration */: return textSpan(node); - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 169 /* Block */: + if (ts.isFunctionBlock(node.parent)) { + return textSpan(node); + } + case 186 /* TryBlock */: + case 203 /* CatchClause */: + case 187 /* FinallyBlock */: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 175 /* SwitchStatement */: + case 182 /* SwitchStatement */: var switchStatement = node.parent; var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1]; if (lastClause) { @@ -24059,23 +25779,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 174 /* DoStatement */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 168 /* WhileStatement */: - case 167 /* DoStatement */: - case 169 /* ForStatement */: + case 156 /* FunctionExpression */: + case 190 /* FunctionDeclaration */: + case 157 /* ArrowFunction */: + case 128 /* MethodDeclaration */: + case 127 /* MethodSignature */: + case 130 /* GetAccessor */: + case 131 /* SetAccessor */: + case 129 /* Constructor */: + case 175 /* WhileStatement */: + case 174 /* DoStatement */: + case 176 /* ForStatement */: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -24083,19 +25804,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isAnyFunction(node.parent) || node.parent.kind === 143 /* PropertyAssignment */) { + if (ts.isAnyFunction(node.parent) || node.parent.kind === 204 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 150 /* TypeAssertion */) { - return spanInNode(node.parent.operand); + if (node.parent.kind === 154 /* TypeAssertionExpression */) { + return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 174 /* DoStatement */) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -24108,82 +25829,6 @@ var ts; var debugObjectHost = this; var ts; (function (ts) { - function languageVersionToScriptTarget(languageVersion) { - if (typeof languageVersion === "undefined") - return undefined; - switch (languageVersion) { - case 0 /* EcmaScript3 */: return 0 /* ES3 */; - case 1 /* EcmaScript5 */: return 1 /* ES5 */; - case 2 /* EcmaScript6 */: return 2 /* ES6 */; - default: throw Error("unsupported LanguageVersion value: " + languageVersion); - } - } - function moduleGenTargetToModuleKind(moduleGenTarget) { - if (typeof moduleGenTarget === "undefined") - return undefined; - switch (moduleGenTarget) { - case 2 /* Asynchronous */: return 2 /* AMD */; - case 1 /* Synchronous */: return 1 /* CommonJS */; - case 0 /* Unspecified */: return 0 /* None */; - default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget); - } - } - function scriptTargetTolanguageVersion(scriptTarget) { - if (typeof scriptTarget === "undefined") - return undefined; - switch (scriptTarget) { - case 0 /* ES3 */: return 0 /* EcmaScript3 */; - case 1 /* ES5 */: return 1 /* EcmaScript5 */; - case 2 /* ES6 */: return 2 /* EcmaScript6 */; - default: throw Error("unsupported ScriptTarget value: " + scriptTarget); - } - } - function moduleKindToModuleGenTarget(moduleKind) { - if (typeof moduleKind === "undefined") - return undefined; - switch (moduleKind) { - case 2 /* AMD */: return 2 /* Asynchronous */; - case 1 /* CommonJS */: return 1 /* Synchronous */; - case 0 /* None */: return 0 /* Unspecified */; - default: throw Error("unsupported ModuleKind value: " + moduleKind); - } - } - function compilationSettingsToCompilerOptions(settings) { - var options = {}; - options.removeComments = settings.removeComments; - options.noResolve = settings.noResolve; - options.noImplicitAny = settings.noImplicitAny; - options.noLib = settings.noLib; - options.target = languageVersionToScriptTarget(settings.codeGenTarget); - options.module = moduleGenTargetToModuleKind(settings.moduleGenTarget); - options.out = settings.outFileOption; - options.outDir = settings.outDirOption; - options.sourceMap = settings.mapSourceFiles; - options.mapRoot = settings.mapRoot; - options.sourceRoot = settings.sourceRoot; - options.declaration = settings.generateDeclarationFiles; - options.codepage = settings.codepage; - options.emitBOM = settings.emitBOM; - return options; - } - function compilerOptionsToCompilationSettings(options) { - var settings = {}; - settings.removeComments = options.removeComments; - settings.noResolve = options.noResolve; - settings.noImplicitAny = options.noImplicitAny; - settings.noLib = options.noLib; - settings.codeGenTarget = scriptTargetTolanguageVersion(options.target); - settings.moduleGenTarget = moduleKindToModuleGenTarget(options.module); - settings.outFileOption = options.out; - settings.outDirOption = options.outDir; - settings.mapSourceFiles = options.sourceMap; - settings.mapRoot = options.mapRoot; - settings.sourceRoot = options.sourceRoot; - settings.generateDeclarationFiles = options.declaration; - settings.codepage = options.codepage; - settings.emitBOM = options.emitBOM; - return settings; - } function logInternalError(logger, err) { logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); } @@ -24222,14 +25867,19 @@ var ts; LanguageServiceShimHostAdapter.prototype.log = function (s) { this.shimHost.log(s); }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + this.shimHost.trace(s); + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; } - var options = compilationSettingsToCompilerOptions(JSON.parse(settingsJson)); - return options; + return JSON.parse(settingsJson); }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -24260,8 +25910,8 @@ var ts; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { return this.shimHost.getCancellationToken(); }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFilename = function () { - return this.shimHost.getDefaultLibFilename(); + LanguageServiceShimHostAdapter.prototype.getDefaultLibFilename = function (options) { + return this.shimHost.getDefaultLibFilename(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -24458,10 +26108,10 @@ var ts; return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, isMemberCompletion) { + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + isMemberCompletion + ")", function () { - var completion = _this.languageService.getCompletionsAtPosition(fileName, position, isMemberCompletion); + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); return completion; }); }; @@ -24589,7 +26239,7 @@ var ts; }; CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { return this.forwardJSONCall("getDefaultCompilationSettings()", function () { - return compilerOptionsToCompilationSettings(ts.getDefaultCompilerOptions()); + return ts.getDefaultCompilerOptions(); }); }; return CoreServicesShimObject; @@ -24599,6 +26249,9 @@ var ts; this._shims = []; this.documentRegistry = ts.createDocumentRegistry(); } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { var hostAdapter = new LanguageServiceShimHostAdapter(host); @@ -24647,6 +26300,9 @@ var ts; return TypeScriptServicesFactory; })(); ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } })(ts || (ts = {})); var TypeScript; (function (TypeScript) {